Compare commits

..
13 changed files with 47 additions and 74 deletions

No files matched your search

@@ -382,7 +382,7 @@ function QualitySection({ user }: { user: CurrentUser }) {
: "This device does not support Dolby Atmos playback."
}
disabled={!dolbyAtmosSupported}
value={dolbyAtmosSupported && (user.preferAtmos ?? false)}
value={user.preferAtmos ?? false}
onValueChange={(checked) =>
void updateAtmos({ preferAtmos: checked }).catch((error: Error) =>
showError(error.message)
+17 -2
View File
@@ -1,4 +1,19 @@
import { requireOptionalNativeModule } from "expo"
import { Platform } from "react-native"
// Android Dolby decoder reports do not reliably indicate working Atmos playback.
export const dolbyAtmosSupported = Platform.OS === "ios"
// E-AC-3 support varies by Android device. Older native builds fail closed.
function supportsDolbyAtmos(): boolean {
if (Platform.OS === "ios") return true
if (Platform.OS !== "android") return false
try {
return (
requireOptionalNativeModule<{
supportsDolbyAtmos?: () => boolean
}>("AudioOutput")?.supportsDolbyAtmos?.() ?? false
)
} catch {
return false
}
}
export const dolbyAtmosSupported = supportsDolbyAtmos()
+2 -3
View File
@@ -1,4 +1,3 @@
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
import { Platform } from "react-native"
import type { AudioSource } from "expo-audio"
@@ -54,7 +53,7 @@ export function songPlayUrl(
const params = new URLSearchParams()
if (Platform.OS === "ios") params.set("losslessFormat", "alac")
if (quality) params.set("quality", quality)
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
if (preferAtmos) params.set("preferAtmos", "true")
const query = params.toString()
return `${serverUrl}/api/song/${songId}/play${query ? `?${query}` : ""}`
}
@@ -67,7 +66,7 @@ export function songHlsPlaylistUrl(
) {
const params = new URLSearchParams()
if (quality) params.set("quality", quality)
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
if (preferAtmos) params.set("preferAtmos", "true")
const query = params.toString()
return `${serverUrl}/api/song/${songId}/play/hls${query ? `?${query}` : ""}`
}
@@ -1,5 +1,6 @@
package expo.modules.audiooutput
import android.media.MediaCodecList
import android.os.Build
import androidx.mediarouter.app.SystemOutputSwitcherDialogController
import expo.modules.kotlin.functions.Queues
@@ -10,6 +11,16 @@ class AudioOutputModule : Module() {
override fun definition() = ModuleDefinition {
Name("AudioOutput")
Function("supportsDolbyAtmos") {
// Library Atmos tracks use E-AC-3. ExoPlayer needs a device decoder.
MediaCodecList(MediaCodecList.REGULAR_CODECS).codecInfos.any { codec ->
!codec.isEncoder && codec.supportedTypes.any { type ->
type.equals("audio/eac3", ignoreCase = true) ||
type.equals("audio/eac3-joc", ignoreCase = true)
}
}
}
AsyncFunction("showPicker") {
val activity = appContext.currentActivity
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || activity == null) {
+1 -5
View File
@@ -1,6 +1,5 @@
"use client"
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
import { Plus } from "lucide-react"
import { useAddToPlaylist } from "@/components/add-to-playlist-provider"
@@ -18,10 +17,7 @@ export default function Page() {
return (
<div className="flex h-svh flex-col">
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
<div className="flex min-w-0 items-center gap-2">
<MobileSidebarTrigger />
<h1 className="text-lg font-semibold">Playlists</h1>
</div>
<h1 className="text-lg font-semibold">Playlists</h1>
<Button
variant="secondary"
size="sm"
+1 -3
View File
@@ -1,6 +1,5 @@
"use client"
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
import { Suspense, useCallback, useEffect, useRef, useState } from "react"
import { SearchIcon } from "lucide-react"
import { usePathname, useSearchParams } from "next/navigation"
@@ -213,8 +212,7 @@ function SearchPageContent() {
return (
<div className="flex h-svh flex-col">
<header className="flex items-center justify-center gap-2 border-b px-4 py-3">
<MobileSidebarTrigger />
<header className="flex items-center justify-center border-b px-4 py-3">
<div className="relative w-full max-w-xl">
<SearchIcon className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
<input
+3 -7
View File
@@ -1,6 +1,5 @@
"use client"
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
import * as React from "react"
import Image from "next/image"
import Link from "next/link"
@@ -392,12 +391,9 @@ export function AlbumView({
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
Album
</p>
<div className="flex min-w-0 items-center justify-center gap-2 sm:justify-start md:contents">
<MobileSidebarTrigger />
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
{album.title}
</h1>
</div>
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
{album.title}
</h1>
<Link
href={"/artist/" + album.artist.id}
className="inline-block text-lg font-semibold text-primary hover:underline"
+3 -5
View File
@@ -35,7 +35,6 @@ import {
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar"
import { ThemeToggle } from "@/components/theme-toggle"
import Image from "next/image"
@@ -64,7 +63,6 @@ const library = [
]
export function AppSidebar() {
const { setOpenMobile } = useSidebar()
const pathname = usePathname()
const router = useRouter()
const { signOut } = useAuthActions()
@@ -122,7 +120,7 @@ export function AppSidebar() {
{browse.map((item) => (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton isActive={pathname === item.path} asChild>
<Link href={item.path} onClick={() => setOpenMobile(false)}>
<Link href={item.path}>
<item.icon />
<span>{item.title}</span>
</Link>
@@ -146,7 +144,7 @@ export function AppSidebar() {
}
asChild
>
<Link href={item.path} onClick={() => setOpenMobile(false)}>
<Link href={item.path}>
<item.icon />
<span>{item.title}</span>
</Link>
@@ -164,7 +162,7 @@ export function AppSidebar() {
{playlistNav.map((item) => (
<SidebarMenuItem key={item.path}>
<SidebarMenuButton isActive={pathname === item.path} asChild>
<Link href={item.path} onClick={() => setOpenMobile(false)}>
<Link href={item.path}>
<item.icon />
<span>{item.title}</span>
</Link>
+3 -7
View File
@@ -1,6 +1,5 @@
"use client"
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
import * as React from "react"
import Image from "next/image"
import { Play, Shuffle } from "lucide-react"
@@ -80,12 +79,9 @@ export function ArtistView({
</div>
<div className="flex min-w-0 flex-1 flex-col gap-4">
<div className="flex min-w-0 items-center gap-2 md:contents">
<MobileSidebarTrigger />
<h1 className="min-w-0 truncate text-3xl font-bold tracking-tight sm:text-4xl lg:text-5xl">
{artist.name}
</h1>
</div>
<h1 className="min-w-0 truncate text-3xl font-bold tracking-tight sm:text-4xl lg:text-5xl">
{artist.name}
</h1>
<div className="flex flex-wrap items-center gap-2">
<Button
@@ -1,4 +1,3 @@
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
import { Skeleton } from "@/components/ui/skeleton"
import { albumGridClassName } from "@/lib/album-grid-classes"
import { TRACK_LIST_CONTAINER } from "@/lib/selection-range-styles"
@@ -22,7 +21,6 @@ function LoadingRegion({
export function PageHeader({ title }: { title: string }) {
return (
<header className="flex items-center gap-2 border-b px-4 py-3">
<MobileSidebarTrigger />
<h1 className="text-lg font-semibold">{title}</h1>
</header>
)
@@ -1,23 +0,0 @@
"use client"
import { Menu } from "lucide-react"
import { Button } from "@/components/ui/button"
import { useSidebar } from "@/components/ui/sidebar"
export function MobileSidebarTrigger() {
const { openMobile, setOpenMobile } = useSidebar()
return (
<Button
variant="ghost"
size="icon"
className="size-11 shrink-0 md:hidden"
aria-label="Open sidebar"
aria-expanded={openMobile}
onClick={() => setOpenMobile(true)}
>
<Menu />
</Button>
)
}
+3 -7
View File
@@ -1,6 +1,5 @@
"use client"
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
import { stationArtistId } from "@/lib/station-artist"
import * as React from "react"
import Image from "next/image"
@@ -545,12 +544,9 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
Playlist
</p>
<div className="flex min-w-0 items-center justify-center gap-2 sm:justify-start md:contents">
<MobileSidebarTrigger />
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
{playlist.title}
</h1>
</div>
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
{playlist.title}
</h1>
<p className="text-lg font-semibold text-primary">
{playlist.owner.name}
</p>
+2 -9
View File
@@ -1,6 +1,5 @@
"use client"
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
import { stationArtistId } from "@/lib/station-artist"
import { useEffect, useMemo, useState, useRef, MouseEvent } from "react"
import Image from "next/image"
@@ -363,10 +362,7 @@ export function SongsView() {
return (
<div className="flex h-svh flex-col">
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
<div className="flex min-w-0 items-center gap-2">
<MobileSidebarTrigger />
<h1 className="text-lg font-semibold">Songs</h1>
</div>
<h1 className="text-lg font-semibold">Songs</h1>
</header>
<SongListSkeleton />
</div>
@@ -376,10 +372,7 @@ export function SongsView() {
return (
<div className="flex h-svh flex-col">
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
<div className="flex min-w-0 items-center gap-2">
<MobileSidebarTrigger />
<h1 className="text-lg font-semibold">Songs</h1>
</div>
<h1 className="text-lg font-semibold">Songs</h1>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon-sm" aria-label="Sort songs">