Compare commits
12
Commits
No files matched your search
@@ -183,7 +183,7 @@ export default function AlbumScreen() {
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={palette.foreground}
|
||||
color={palette.isDark ? "#fff" : "#000"}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
|
||||
@@ -39,10 +39,7 @@ import { contentBottomInset, SongListRow } from "@/components/player"
|
||||
import { useFavorites } from "@/contexts/favorites"
|
||||
import { usePlaybackActions } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import {
|
||||
useCachedPaginatedQuery,
|
||||
useCachedQuery,
|
||||
} from "@/hooks/use-cached-query"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import { useCoverPalette } from "@/hooks/use-cover-palette"
|
||||
import { useMediaMenuActions } from "@/hooks/use-media-menu-actions"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
@@ -55,7 +52,6 @@ import { showError } from "@/lib/toast"
|
||||
import { playlistCoverUrl } from "@/lib/urls"
|
||||
import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
|
||||
const PAGE_SIZE = 50
|
||||
const PLAYLIST_LABEL = "Add to Another Playlist"
|
||||
const OWNER_MENU_ACTIONS: MediaAction[] = [
|
||||
"share",
|
||||
@@ -74,27 +70,9 @@ export default function PlaylistScreen() {
|
||||
const playlistId = typeof id === "string" ? (id as Id<"playlists">) : null
|
||||
const playlist = useCachedQuery(
|
||||
api.playlists.browsePlaylistDetail,
|
||||
playlistId
|
||||
? {
|
||||
id: playlistId,
|
||||
includeSongs: false,
|
||||
}
|
||||
: "skip"
|
||||
)
|
||||
const {
|
||||
results: songs,
|
||||
status,
|
||||
loadMore,
|
||||
isCached,
|
||||
} = useCachedPaginatedQuery(
|
||||
api.playlists.browsePlaylistSongsPaginated,
|
||||
playlistId ? { id: playlistId } : "skip",
|
||||
{ initialNumItems: PAGE_SIZE }
|
||||
)
|
||||
const allSongIds = useCachedQuery(
|
||||
api.playlists.getPlaylistSongIds,
|
||||
playlistId ? { playlistId } : "skip"
|
||||
playlistId ? { id: playlistId } : "skip"
|
||||
)
|
||||
const songs = playlist?.songs
|
||||
const coverUri =
|
||||
config && playlistId
|
||||
? playlistCoverUrl(config.serverUrl, playlist?.id ?? playlistId)
|
||||
@@ -106,15 +84,10 @@ export default function PlaylistScreen() {
|
||||
const { palette, onLayout } = useAndroidScreenPalette(artworkPalette)
|
||||
|
||||
useEffect(() => {
|
||||
rememberSongs(songs)
|
||||
if (songs) rememberSongs(songs)
|
||||
}, [songs])
|
||||
|
||||
if (
|
||||
playlist === undefined ||
|
||||
(status === "LoadingFirstPage" && !isCached) ||
|
||||
!config ||
|
||||
!settled
|
||||
) {
|
||||
if (playlist === undefined || !config || !settled) {
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
@@ -150,13 +123,9 @@ export default function PlaylistScreen() {
|
||||
<PlaylistContent
|
||||
onLayout={onLayout}
|
||||
playlist={playlist}
|
||||
songs={songs}
|
||||
allSongIds={allSongIds}
|
||||
songs={playlist.songs}
|
||||
coverUri={coverUri}
|
||||
palette={palette}
|
||||
onEndReached={() => {
|
||||
if (status === "CanLoadMore") loadMore(PAGE_SIZE)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -165,18 +134,14 @@ function PlaylistContent({
|
||||
onLayout,
|
||||
playlist,
|
||||
songs,
|
||||
allSongIds,
|
||||
coverUri,
|
||||
palette,
|
||||
onEndReached,
|
||||
}: {
|
||||
onLayout?: () => void
|
||||
playlist: BrowsePlaylistDetail
|
||||
songs: BrowseSong[]
|
||||
allSongIds: Id<"songs">[] | undefined
|
||||
coverUri: string
|
||||
palette: CoverPalette
|
||||
onEndReached: () => void
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const isFocused = useIsFocused()
|
||||
@@ -192,8 +157,7 @@ function PlaylistContent({
|
||||
const playlistId = playlist.id
|
||||
const isSubscribed = playlist.isSubscribed
|
||||
const canEdit = playlist.isOwner && playlistId !== null
|
||||
const loadedSongIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
const songIds = allSongIds ?? loadedSongIds
|
||||
const songIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
const swipeGroup = useSwipeRowGroup()
|
||||
|
||||
const handlePlaySong = useCallback(
|
||||
@@ -226,12 +190,12 @@ function PlaylistContent({
|
||||
)
|
||||
|
||||
const handlePlay = useCallback(() => {
|
||||
if (playlistId) void playPlaylist(playlistId, allSongIds)
|
||||
}, [allSongIds, playPlaylist, playlistId])
|
||||
if (playlistId) void playPlaylist(playlistId, songIds)
|
||||
}, [playPlaylist, playlistId, songIds])
|
||||
|
||||
const handleShuffle = useCallback(() => {
|
||||
if (playlistId) void playPlaylistShuffled(playlistId, allSongIds)
|
||||
}, [allSongIds, playPlaylistShuffled, playlistId])
|
||||
if (playlistId) void playPlaylistShuffled(playlistId, songIds)
|
||||
}, [playPlaylistShuffled, playlistId, songIds])
|
||||
|
||||
const handleSubscribeToggle = useCallback(async () => {
|
||||
if (!playlistId) return
|
||||
@@ -297,7 +261,7 @@ function PlaylistContent({
|
||||
<Ionicons
|
||||
name="ellipsis-horizontal"
|
||||
size={22}
|
||||
color={palette.foreground}
|
||||
color={palette.isDark ? "#fff" : "#000"}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaActionMenu>
|
||||
@@ -355,8 +319,6 @@ function PlaylistContent({
|
||||
indicatorStyle={palette.isDark ? "white" : "black"}
|
||||
contentContainerStyle={styles.listContent}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
onEndReached={onEndReached}
|
||||
onEndReachedThreshold={0.5}
|
||||
onScrollBeginDrag={swipeGroup.closeOpenRow}
|
||||
ListHeaderComponent={
|
||||
<PlaylistHero
|
||||
|
||||
@@ -15,10 +15,7 @@ import { contentBottomInset, SongListRow } from "@/components/player"
|
||||
import { useFavorites } from "@/contexts/favorites"
|
||||
import { usePlaybackActions } from "@/contexts/playback"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import {
|
||||
useCachedPaginatedQuery,
|
||||
useCachedQuery,
|
||||
} from "@/hooks/use-cached-query"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import { useMediaMenuActions } from "@/hooks/use-media-menu-actions"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { MediaAction } from "@/components/media-context-menu"
|
||||
@@ -29,32 +26,21 @@ import { radius, spacing, useThemeColors } from "@/lib/theme"
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { Stack } from "expo-router"
|
||||
|
||||
const PAGE_SIZE = 50
|
||||
const SCREEN_OPTIONS = { title: "", headerLargeTitle: false }
|
||||
|
||||
export default function FavoritesScreen() {
|
||||
const colors = useThemeColors()
|
||||
const { config } = useServerConfig()
|
||||
const favorites = useCachedQuery(api.favorites.browseFavoritesSummary)
|
||||
const {
|
||||
results: songs,
|
||||
status,
|
||||
loadMore,
|
||||
isCached,
|
||||
} = useCachedPaginatedQuery(
|
||||
api.favorites.browseFavoritesSongsPaginated,
|
||||
{},
|
||||
{ initialNumItems: PAGE_SIZE }
|
||||
)
|
||||
const favorites = useCachedQuery(api.favorites.browseFavoritesPlaylistDetail)
|
||||
const songs = favorites?.songs ?? []
|
||||
const { playInOrder, playShuffled, playFromSong } = usePlaybackActions()
|
||||
const { isSongFavorite } = useFavorites()
|
||||
const { handleSongAction } = useMediaMenuActions()
|
||||
const loadedSongIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
const songIds = favorites?.songIds ?? loadedSongIds
|
||||
const songIds = useMemo(() => songs.map((song) => song.id), [songs])
|
||||
|
||||
useEffect(() => {
|
||||
rememberSongs(songs)
|
||||
}, [songs])
|
||||
if (favorites) rememberSongs(favorites.songs)
|
||||
}, [favorites])
|
||||
|
||||
const handlePlaySong = useCallback(
|
||||
(song: BrowseSong) => void playFromSong(song.id, songIds),
|
||||
@@ -88,11 +74,7 @@ export default function FavoritesScreen() {
|
||||
[handlePlaySong, handleSongMenuAction, isSongFavorite]
|
||||
)
|
||||
|
||||
if (
|
||||
favorites === undefined ||
|
||||
(status === "LoadingFirstPage" && !isCached) ||
|
||||
!config
|
||||
) {
|
||||
if (favorites === undefined || !config) {
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen options={SCREEN_OPTIONS} />
|
||||
@@ -125,10 +107,6 @@ export default function FavoritesScreen() {
|
||||
style={{ flex: 1, backgroundColor: colors.background }}
|
||||
contentContainerStyle={styles.listContent}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
onEndReached={() => {
|
||||
if (status === "CanLoadMore") loadMore(PAGE_SIZE)
|
||||
}}
|
||||
onEndReachedThreshold={0.5}
|
||||
ListHeaderComponent={
|
||||
<FavoritesHero
|
||||
title={favorites.title}
|
||||
|
||||
@@ -382,7 +382,7 @@ function QualitySection({ user }: { user: CurrentUser }) {
|
||||
: "This device does not support Dolby Atmos playback."
|
||||
}
|
||||
disabled={!dolbyAtmosSupported}
|
||||
value={user.preferAtmos ?? false}
|
||||
value={dolbyAtmosSupported && (user.preferAtmos ?? false)}
|
||||
onValueChange={(checked) =>
|
||||
void updateAtmos({ preferAtmos: checked }).catch((error: Error) =>
|
||||
showError(error.message)
|
||||
|
||||
@@ -2,6 +2,7 @@ import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import {
|
||||
createAudioPlaylist,
|
||||
setAudioModeAsync,
|
||||
setIsAudioActiveAsync,
|
||||
type AudioMetadata,
|
||||
type AudioPlaylist,
|
||||
type AudioPlaylistStatus,
|
||||
@@ -774,6 +775,14 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
playlist.play()
|
||||
} else {
|
||||
playlist.pause()
|
||||
// Enable audio for the restored queue without starting playback.
|
||||
try {
|
||||
await setIsAudioActiveAsync(true)
|
||||
} catch {
|
||||
if (isCurrentLoad()) {
|
||||
showError("Audio playback could not be initialized.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
import { requireOptionalNativeModule } from "expo"
|
||||
import { Platform } from "react-native"
|
||||
|
||||
// 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()
|
||||
// Android Dolby decoder reports do not reliably indicate working Atmos playback.
|
||||
export const dolbyAtmosSupported = Platform.OS === "ios"
|
||||
@@ -1,3 +1,4 @@
|
||||
import { dolbyAtmosSupported } from "@/lib/playback-capabilities"
|
||||
import { Platform } from "react-native"
|
||||
import type { AudioSource } from "expo-audio"
|
||||
|
||||
@@ -53,7 +54,7 @@ export function songPlayUrl(
|
||||
const params = new URLSearchParams()
|
||||
if (Platform.OS === "ios") params.set("losslessFormat", "alac")
|
||||
if (quality) params.set("quality", quality)
|
||||
if (preferAtmos) params.set("preferAtmos", "true")
|
||||
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
|
||||
const query = params.toString()
|
||||
return `${serverUrl}/api/song/${songId}/play${query ? `?${query}` : ""}`
|
||||
}
|
||||
@@ -66,7 +67,7 @@ export function songHlsPlaylistUrl(
|
||||
) {
|
||||
const params = new URLSearchParams()
|
||||
if (quality) params.set("quality", quality)
|
||||
if (preferAtmos) params.set("preferAtmos", "true")
|
||||
if (dolbyAtmosSupported && preferAtmos) params.set("preferAtmos", "true")
|
||||
const query = params.toString()
|
||||
return `${serverUrl}/api/song/${songId}/play/hls${query ? `?${query}` : ""}`
|
||||
}
|
||||
|
||||
-11
@@ -1,6 +1,5 @@
|
||||
package expo.modules.audiooutput
|
||||
|
||||
import android.media.MediaCodecList
|
||||
import android.os.Build
|
||||
import androidx.mediarouter.app.SystemOutputSwitcherDialogController
|
||||
import expo.modules.kotlin.functions.Queues
|
||||
@@ -11,16 +10,6 @@ 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) {
|
||||
|
||||
@@ -26,8 +26,9 @@ final class AudioOutputView: ExpoView {
|
||||
super.init(appContext: appContext)
|
||||
picker.prioritizesVideoDevices = false
|
||||
picker.backgroundColor = .clear
|
||||
// Keep the native picker interactive without its route-dependent icon styling.
|
||||
picker.layer.opacity = 0
|
||||
// Hide only the native glyph. Making the picker transparent prevents taps.
|
||||
picker.tintColor = .clear
|
||||
picker.activeTintColor = .clear
|
||||
addSubview(picker)
|
||||
icon.contentMode = .center
|
||||
icon.isUserInteractionEnabled = false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||
import { Plus } from "lucide-react"
|
||||
|
||||
import { useAddToPlaylist } from "@/components/add-to-playlist-provider"
|
||||
@@ -17,7 +18,10 @@ 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">
|
||||
<h1 className="text-lg font-semibold">Playlists</h1>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<MobileSidebarTrigger />
|
||||
<h1 className="text-lg font-semibold">Playlists</h1>
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"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"
|
||||
@@ -212,7 +213,8 @@ function SearchPageContent() {
|
||||
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<header className="flex items-center justify-center border-b px-4 py-3">
|
||||
<header className="flex items-center justify-center gap-2 border-b px-4 py-3">
|
||||
<MobileSidebarTrigger />
|
||||
<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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { Id } from "@otunes/convex/_generated/dataModel"
|
||||
import { audioContentTypeForPath } from "@/lib/audio-content-type"
|
||||
import { seekableLosslessFile } from "@/lib/server-lossless"
|
||||
import { getConvexClient } from "@/lib/convex-server"
|
||||
import { ffmpegToReadableStream, streamFile } from "@/lib/server-audio-stream"
|
||||
import { NextRequest, NextResponse, userAgent } from "next/server"
|
||||
@@ -169,26 +170,9 @@ export async function GET(
|
||||
}
|
||||
}
|
||||
|
||||
const ffmpegArgs = [
|
||||
"-nostdin",
|
||||
"-i",
|
||||
song.files[originalCodec],
|
||||
"-f",
|
||||
"flac",
|
||||
"pipe:1",
|
||||
]
|
||||
|
||||
try {
|
||||
const ffmpegProcess = spawn("ffmpeg", ffmpegArgs)
|
||||
const stream = ffmpegToReadableStream(ffmpegProcess)
|
||||
|
||||
return new NextResponse(stream, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "audio/flac",
|
||||
"Cache-Control": "no-cache",
|
||||
},
|
||||
})
|
||||
const file = await seekableLosslessFile(song.files[originalCodec])
|
||||
return await streamFileResponse(request, file, "audio/flac")
|
||||
} catch {
|
||||
return new Response("Server Error", { status: 500 })
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||
import * as React from "react"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
@@ -391,9 +392,12 @@ export function AlbumView({
|
||||
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
||||
Album
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
|
||||
{album.title}
|
||||
</h1>
|
||||
<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>
|
||||
<Link
|
||||
href={"/artist/" + album.artist.id}
|
||||
className="inline-block text-lg font-semibold text-primary hover:underline"
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
SidebarMenu,
|
||||
SidebarMenuButton,
|
||||
SidebarMenuItem,
|
||||
useSidebar,
|
||||
} from "@/components/ui/sidebar"
|
||||
import { ThemeToggle } from "@/components/theme-toggle"
|
||||
import Image from "next/image"
|
||||
@@ -63,6 +64,7 @@ const library = [
|
||||
]
|
||||
|
||||
export function AppSidebar() {
|
||||
const { setOpenMobile } = useSidebar()
|
||||
const pathname = usePathname()
|
||||
const router = useRouter()
|
||||
const { signOut } = useAuthActions()
|
||||
@@ -120,7 +122,7 @@ export function AppSidebar() {
|
||||
{browse.map((item) => (
|
||||
<SidebarMenuItem key={item.title}>
|
||||
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
||||
<Link href={item.path}>
|
||||
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
@@ -144,7 +146,7 @@ export function AppSidebar() {
|
||||
}
|
||||
asChild
|
||||
>
|
||||
<Link href={item.path}>
|
||||
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
@@ -162,7 +164,7 @@ export function AppSidebar() {
|
||||
{playlistNav.map((item) => (
|
||||
<SidebarMenuItem key={item.path}>
|
||||
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
||||
<Link href={item.path}>
|
||||
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||
<item.icon />
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"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"
|
||||
@@ -79,9 +80,12 @@ export function ArtistView({
|
||||
</div>
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-4">
|
||||
<h1 className="min-w-0 truncate text-3xl font-bold tracking-tight sm:text-4xl lg:text-5xl">
|
||||
{artist.name}
|
||||
</h1>
|
||||
<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>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Button
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
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"
|
||||
@@ -21,6 +22,7 @@ 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>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"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>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
"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"
|
||||
@@ -544,9 +545,12 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
||||
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
||||
Playlist
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
|
||||
{playlist.title}
|
||||
</h1>
|
||||
<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>
|
||||
<p className="text-lg font-semibold text-primary">
|
||||
{playlist.owner.name}
|
||||
</p>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"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"
|
||||
@@ -362,7 +363,10 @@ 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">
|
||||
<h1 className="text-lg font-semibold">Songs</h1>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<MobileSidebarTrigger />
|
||||
<h1 className="text-lg font-semibold">Songs</h1>
|
||||
</div>
|
||||
</header>
|
||||
<SongListSkeleton />
|
||||
</div>
|
||||
@@ -372,7 +376,10 @@ 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">
|
||||
<h1 className="text-lg font-semibold">Songs</h1>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<MobileSidebarTrigger />
|
||||
<h1 className="text-lg font-semibold">Songs</h1>
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon-sm" aria-label="Sort songs">
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { spawn } from "node:child_process"
|
||||
import { createHash } from "node:crypto"
|
||||
import fs from "node:fs/promises"
|
||||
import os from "node:os"
|
||||
import path from "node:path"
|
||||
|
||||
const conversions = new Map<string, Promise<string>>()
|
||||
|
||||
// A completed FLAC file has a duration and supports byte ranges. Piped FLAC does not.
|
||||
export async function seekableLosslessFile(source: string): Promise<string> {
|
||||
if (path.extname(source).toLowerCase() === ".flac") return source
|
||||
|
||||
const stat = await fs.stat(source)
|
||||
const key = createHash("sha256")
|
||||
.update(`${source}:${stat.size}:${stat.mtimeMs}`)
|
||||
.digest("hex")
|
||||
const existing = conversions.get(key)
|
||||
if (existing) return existing
|
||||
|
||||
const conversion = convert(source, key)
|
||||
conversions.set(key, conversion)
|
||||
try {
|
||||
return await conversion
|
||||
} finally {
|
||||
conversions.delete(key)
|
||||
}
|
||||
}
|
||||
|
||||
async function convert(source: string, key: string): Promise<string> {
|
||||
const dir = path.join(os.tmpdir(), "otunes-lossless")
|
||||
await fs.mkdir(dir, { recursive: true })
|
||||
const cutoff = Date.now() - 30 * 60 * 1000
|
||||
await Promise.all(
|
||||
(await fs.readdir(dir))
|
||||
.filter((name) => name.endsWith(".flac"))
|
||||
.map(async (name) => {
|
||||
const file = path.join(dir, name)
|
||||
const stat = await fs.stat(file).catch(() => null)
|
||||
if (stat && stat.mtimeMs < cutoff) await fs.rm(file, { force: true })
|
||||
})
|
||||
)
|
||||
const output = path.join(dir, `${key}.flac`)
|
||||
try {
|
||||
await fs.access(output)
|
||||
return output
|
||||
} catch {
|
||||
// Publish only completed conversions so range requests always see a complete file.
|
||||
}
|
||||
const temporary = path.join(
|
||||
await fs.mkdtemp(path.join(dir, "convert-")),
|
||||
"audio.flac"
|
||||
)
|
||||
try {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const child = spawn(
|
||||
"ffmpeg",
|
||||
[
|
||||
"-nostdin",
|
||||
"-v",
|
||||
"error",
|
||||
"-i",
|
||||
source,
|
||||
"-map",
|
||||
"0:a:0",
|
||||
"-c:a",
|
||||
"flac",
|
||||
temporary,
|
||||
],
|
||||
{ stdio: "ignore" }
|
||||
)
|
||||
child.on("error", reject)
|
||||
child.on("close", (code) => {
|
||||
if (code === 0) resolve()
|
||||
else reject(new Error(`Lossless conversion failed: ${code}`))
|
||||
})
|
||||
})
|
||||
await fs.rename(temporary, output)
|
||||
return output
|
||||
} finally {
|
||||
await fs.rm(path.dirname(temporary), { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
@@ -159,3 +159,169 @@ diff --git a/build/Audio.types.d.ts b/build/Audio.types.d.ts
|
||||
+ /** MIME type for streams whose URL has no file extension, such as HLS. */
|
||||
+ mimeType?: string;
|
||||
/**
|
||||
diff --git a/android/src/main/java/expo/modules/audio/BaseAudioPlayer.kt b/android/src/main/java/expo/modules/audio/BaseAudioPlayer.kt
|
||||
--- a/android/src/main/java/expo/modules/audio/BaseAudioPlayer.kt
|
||||
+++ b/android/src/main/java/expo/modules/audio/BaseAudioPlayer.kt
|
||||
@@ -159,8 +159,16 @@
|
||||
super.sharedObjectDidRelease()
|
||||
// Run on GlobalScope (not appContext.mainQueue) so that reloading doesn't cancel the release process
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
- releasePlayer()
|
||||
+ release()
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ private var released = false
|
||||
+
|
||||
+ fun release() {
|
||||
+ if (released) return
|
||||
+ released = true
|
||||
+ releasePlayer()
|
||||
}
|
||||
|
||||
protected open fun releasePlayer() {
|
||||
diff --git a/android/src/main/java/expo/modules/audio/AudioModule.kt b/android/src/main/java/expo/modules/audio/AudioModule.kt
|
||||
--- a/android/src/main/java/expo/modules/audio/AudioModule.kt
|
||||
+++ b/android/src/main/java/expo/modules/audio/AudioModule.kt
|
||||
@@ -1105,6 +1105,7 @@
|
||||
runOnMain {
|
||||
playlist.clearLockScreenControls()
|
||||
playlists.remove(playlist.id)
|
||||
+ playlist.release()
|
||||
releaseAudioFocusIfUnused()
|
||||
}
|
||||
}
|
||||
diff --git a/android/src/main/java/expo/modules/audio/service/MetadataInjectingPlayer.kt b/android/src/main/java/expo/modules/audio/service/MetadataInjectingPlayer.kt
|
||||
--- a/android/src/main/java/expo/modules/audio/service/MetadataInjectingPlayer.kt
|
||||
+++ b/android/src/main/java/expo/modules/audio/service/MetadataInjectingPlayer.kt
|
||||
@@ -1,5 +1,14 @@
|
||||
package expo.modules.audio.service
|
||||
|
||||
+import androidx.media3.common.AudioAttributes
|
||||
+import androidx.media3.common.DeviceInfo
|
||||
+import androidx.media3.common.MediaItem
|
||||
+import androidx.media3.common.PlaybackException
|
||||
+import androidx.media3.common.PlaybackParameters
|
||||
+import androidx.media3.common.Timeline
|
||||
+import androidx.media3.common.TrackSelectionParameters
|
||||
+import androidx.media3.common.Tracks
|
||||
+import androidx.media3.common.VideoSize
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.core.net.toUri
|
||||
@@ -81,7 +90,114 @@
|
||||
|
||||
private inner class MetadataForwardingListener(
|
||||
private val listener: Player.Listener
|
||||
- ) : Player.Listener by listener {
|
||||
+ ) : Player.Listener {
|
||||
+ // Kotlin delegation does not forward Java default methods on Player.Listener.
|
||||
+ // Forward each callback so MediaSession receives timeline and duration changes.
|
||||
+ override fun onTimelineChanged(timeline: Timeline, reason: Int) =
|
||||
+ listener.onTimelineChanged(timeline, reason)
|
||||
+
|
||||
+ override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) =
|
||||
+ listener.onMediaItemTransition(mediaItem, reason)
|
||||
+
|
||||
+ override fun onTracksChanged(tracks: Tracks) =
|
||||
+ listener.onTracksChanged(tracks)
|
||||
+
|
||||
+ override fun onPlaylistMetadataChanged(mediaMetadata: MediaMetadata) =
|
||||
+ listener.onPlaylistMetadataChanged(mediaMetadata)
|
||||
+
|
||||
+ override fun onIsLoadingChanged(isLoading: Boolean) =
|
||||
+ listener.onIsLoadingChanged(isLoading)
|
||||
+
|
||||
+ override fun onLoadingChanged(isLoading: Boolean) =
|
||||
+ listener.onLoadingChanged(isLoading)
|
||||
+
|
||||
+ override fun onAvailableCommandsChanged(availableCommands: Player.Commands) =
|
||||
+ listener.onAvailableCommandsChanged(availableCommands)
|
||||
+
|
||||
+ override fun onTrackSelectionParametersChanged(parameters: TrackSelectionParameters) =
|
||||
+ listener.onTrackSelectionParametersChanged(parameters)
|
||||
+
|
||||
+ override fun onPlayerStateChanged(playWhenReady: Boolean, playbackState: Int) =
|
||||
+ listener.onPlayerStateChanged(playWhenReady, playbackState)
|
||||
+
|
||||
+ override fun onPlaybackStateChanged(playbackState: Int) =
|
||||
+ listener.onPlaybackStateChanged(playbackState)
|
||||
+
|
||||
+ override fun onPlayWhenReadyChanged(playWhenReady: Boolean, reason: Int) =
|
||||
+ listener.onPlayWhenReadyChanged(playWhenReady, reason)
|
||||
+
|
||||
+ override fun onPlaybackSuppressionReasonChanged(playbackSuppressionReason: Int) =
|
||||
+ listener.onPlaybackSuppressionReasonChanged(playbackSuppressionReason)
|
||||
+
|
||||
+ override fun onIsPlayingChanged(isPlaying: Boolean) =
|
||||
+ listener.onIsPlayingChanged(isPlaying)
|
||||
+
|
||||
+ override fun onRepeatModeChanged(repeatMode: Int) =
|
||||
+ listener.onRepeatModeChanged(repeatMode)
|
||||
+
|
||||
+ override fun onShuffleModeEnabledChanged(shuffleModeEnabled: Boolean) =
|
||||
+ listener.onShuffleModeEnabledChanged(shuffleModeEnabled)
|
||||
+
|
||||
+ override fun onPlayerError(error: PlaybackException) =
|
||||
+ listener.onPlayerError(error)
|
||||
+
|
||||
+ override fun onPlayerErrorChanged(error: PlaybackException?) =
|
||||
+ listener.onPlayerErrorChanged(error)
|
||||
+
|
||||
+ override fun onPositionDiscontinuity(reason: Int) =
|
||||
+ listener.onPositionDiscontinuity(reason)
|
||||
+
|
||||
+ override fun onPositionDiscontinuity(oldPosition: Player.PositionInfo, newPosition: Player.PositionInfo, reason: Int) =
|
||||
+ listener.onPositionDiscontinuity(oldPosition, newPosition, reason)
|
||||
+
|
||||
+ override fun onPlaybackParametersChanged(playbackParameters: PlaybackParameters) =
|
||||
+ listener.onPlaybackParametersChanged(playbackParameters)
|
||||
+
|
||||
+ override fun onSeekBackIncrementChanged(seekBackIncrementMs: Long) =
|
||||
+ listener.onSeekBackIncrementChanged(seekBackIncrementMs)
|
||||
+
|
||||
+ override fun onSeekForwardIncrementChanged(seekForwardIncrementMs: Long) =
|
||||
+ listener.onSeekForwardIncrementChanged(seekForwardIncrementMs)
|
||||
+
|
||||
+ override fun onMaxSeekToPreviousPositionChanged(maxSeekToPreviousPositionMs: Long) =
|
||||
+ listener.onMaxSeekToPreviousPositionChanged(maxSeekToPreviousPositionMs)
|
||||
+
|
||||
+ override fun onAudioSessionIdChanged(audioSessionId: Int) =
|
||||
+ listener.onAudioSessionIdChanged(audioSessionId)
|
||||
+
|
||||
+ override fun onAudioAttributesChanged(audioAttributes: AudioAttributes) =
|
||||
+ listener.onAudioAttributesChanged(audioAttributes)
|
||||
+
|
||||
+ override fun onVolumeChanged(volume: Float) =
|
||||
+ listener.onVolumeChanged(volume)
|
||||
+
|
||||
+ override fun onSkipSilenceEnabledChanged(skipSilenceEnabled: Boolean) =
|
||||
+ listener.onSkipSilenceEnabledChanged(skipSilenceEnabled)
|
||||
+
|
||||
+ override fun onDeviceInfoChanged(deviceInfo: DeviceInfo) =
|
||||
+ listener.onDeviceInfoChanged(deviceInfo)
|
||||
+
|
||||
+ override fun onDeviceVolumeChanged(volume: Int, muted: Boolean) =
|
||||
+ listener.onDeviceVolumeChanged(volume, muted)
|
||||
+
|
||||
+ override fun onVideoSizeChanged(videoSize: VideoSize) =
|
||||
+ listener.onVideoSizeChanged(videoSize)
|
||||
+
|
||||
+ override fun onSurfaceSizeChanged(width: Int, height: Int) =
|
||||
+ listener.onSurfaceSizeChanged(width, height)
|
||||
+
|
||||
+ override fun onRenderedFirstFrame() =
|
||||
+ listener.onRenderedFirstFrame()
|
||||
+
|
||||
+ override fun onCues(cues: List<androidx.media3.common.text.Cue>) =
|
||||
+ listener.onCues(cues)
|
||||
+
|
||||
+ override fun onCues(cueGroup: androidx.media3.common.text.CueGroup) =
|
||||
+ listener.onCues(cueGroup)
|
||||
+
|
||||
+ override fun onMetadata(metadata: androidx.media3.common.Metadata) =
|
||||
+ listener.onMetadata(metadata)
|
||||
+
|
||||
override fun onMediaMetadataChanged(mediaMetadata: MediaMetadata) {
|
||||
listener.onMediaMetadataChanged(this@MetadataInjectingPlayer.mediaMetadata)
|
||||
}
|
||||
Generated
+3
-3
@@ -6,7 +6,7 @@ settings:
|
||||
|
||||
patchedDependencies:
|
||||
expo-audio@58.0.10:
|
||||
hash: e01ad6e484db76d810c2df5bf9c376eccf8d4c5359736b626868ea8bd8dac566
|
||||
hash: f7f102c0f17b28e763d828acd4f138d62809f5be576e316a13008c27e84968c5
|
||||
path: patches/expo-audio@58.0.10.patch
|
||||
|
||||
importers:
|
||||
@@ -63,7 +63,7 @@ importers:
|
||||
version: 58.0.18(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3)
|
||||
expo-audio:
|
||||
specifier: ~58.0.10
|
||||
version: 58.0.10(patch_hash=e01ad6e484db76d810c2df5bf9c376eccf8d4c5359736b626868ea8bd8dac566)(expo-asset@58.0.18(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3))(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
version: 58.0.10(patch_hash=f7f102c0f17b28e763d828acd4f138d62809f5be576e316a13008c27e84968c5)(expo-asset@58.0.18(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3))(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
expo-blur:
|
||||
specifier: ~58.0.5
|
||||
version: 58.0.5(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
@@ -11073,7 +11073,7 @@ snapshots:
|
||||
- supports-color
|
||||
- typescript
|
||||
|
||||
expo-audio@58.0.10(patch_hash=e01ad6e484db76d810c2df5bf9c376eccf8d4c5359736b626868ea8bd8dac566)(expo-asset@58.0.18(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3))(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
expo-audio@58.0.10(patch_hash=f7f102c0f17b28e763d828acd4f138d62809f5be576e316a13008c27e84968c5)(expo-asset@58.0.18(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3))(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
dependencies:
|
||||
expo: 58.0.17(@babel/core@7.29.7)(@expo/dom-webview@58.0.2)(@expo/metro-runtime@58.0.15)(expo-router@58.0.25)(react-dom@19.3.0(react@19.3.0))(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3)
|
||||
expo-asset: 58.0.18(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3)
|
||||
|
||||
Reference in new issue
Block a user