From c7e2eb1a42f359efb51e0d7a641e6f2d24989922 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Tue, 3 Nov 2026 14:40:08 -0500 Subject: [PATCH] feat: show album audio formats and refresh the web player (#61) --- .../app/(app)/(tabs)/home/album/[id].tsx | 63 +++++- apps/web/app/(app)/[...not-found]/page.tsx | 3 + apps/web/app/(app)/search/loading.tsx | 4 +- apps/web/components/album-view.tsx | 51 ++++- apps/web/components/artist-view.tsx | 12 +- apps/web/components/audio-format-badge.tsx | 99 ++++++++ apps/web/components/library-skeletons.tsx | 13 +- apps/web/components/page-message.tsx | 3 + apps/web/components/playback-provider.tsx | 18 +- apps/web/components/player-bar.tsx | 211 ++++++++++-------- apps/web/components/playlist-view.tsx | 12 +- apps/web/components/ui/slider.tsx | 2 + packages/convex/convex/library.ts | 4 + packages/convex/convex/types.ts | 2 + 14 files changed, 373 insertions(+), 124 deletions(-) create mode 100644 apps/web/components/audio-format-badge.tsx diff --git a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx index 9fc6536..54632b2 100644 --- a/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx +++ b/apps/mobile/app/(app)/(tabs)/home/album/[id].tsx @@ -18,6 +18,7 @@ import { collectionInset, DiscHeader, } from "@/components/collection-list" +import { AudioFormatBadge } from "@/components/audio-format-badge" import { CoverImage } from "@/components/cover-image" import { @@ -75,6 +76,20 @@ export default function AlbumScreen() { [album] ) + // Older servers do not include album format availability yet. + const formatTracks = useCachedQuery( + api.library.getSongsForPlayback, + album && (album.hasLossless === undefined || album.hasAtmos === undefined) + ? { ids: songIds } + : "skip" + ) + const hasLossless = + album?.hasLossless ?? + formatTracks?.some((track) => track && "lossless" in track.files) + const hasAtmos = + album?.hasAtmos ?? + formatTracks?.some((track) => track && "atmos" in track.files) + useEffect(() => { if (album) { rememberSongs(albumDetailSongs(album)) @@ -218,11 +233,49 @@ export default function AlbumScreen() { {album.artist.name} - {metadata ? ( - - {metadata} - - ) : null} + + {metadata ? ( + + {metadata} + + ) : null} + {hasLossless ? ( + <> + {metadata ? ( + + · + + ) : null} + + + ) : null} + {hasAtmos ? ( + <> + {metadata || hasLossless ? ( + + · + + ) : null} + + + ) : null} + void toggleAlbumFavorite(album.id)} diff --git a/apps/web/app/(app)/[...not-found]/page.tsx b/apps/web/app/(app)/[...not-found]/page.tsx index e683d5b..e31dd2b 100644 --- a/apps/web/app/(app)/[...not-found]/page.tsx +++ b/apps/web/app/(app)/[...not-found]/page.tsx @@ -1,5 +1,7 @@ "use client" +import { PageHeader } from "@/components/library-skeletons" + import Link from "next/link" import { Home, Search } from "lucide-react" @@ -8,6 +10,7 @@ import { Button } from "@/components/ui/button" export default function Page() { return (
+

404

diff --git a/apps/web/app/(app)/search/loading.tsx b/apps/web/app/(app)/search/loading.tsx index 7c5e0f5..6ff975c 100644 --- a/apps/web/app/(app)/search/loading.tsx +++ b/apps/web/app/(app)/search/loading.tsx @@ -2,6 +2,7 @@ import { useSearchParams } from "next/navigation" +import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger" import { SearchResultsSkeleton } from "@/components/library-skeletons" import { SearchPrompt } from "@/components/search-prompt" import { Skeleton } from "@/components/ui/skeleton" @@ -11,7 +12,8 @@ export default function Loading() { return (
-
+
+
{hasQuery ? : } diff --git a/apps/web/components/album-view.tsx b/apps/web/components/album-view.tsx index 156abfb..cb426ea 100644 --- a/apps/web/components/album-view.tsx +++ b/apps/web/components/album-view.tsx @@ -1,11 +1,12 @@ "use client" -import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger" +import { PageHeader } from "@/components/library-skeletons" import * as React from "react" import Image from "next/image" import Link from "next/link" import { Play, Share2, Shuffle, Star } from "lucide-react" +import { AudioFormatBadge } from "@/components/audio-format-badge" import { MediaCollectionFooter } from "@/components/media-collection-footer" import { TrackNumberPlayButton } from "@/components/track-number-play-button" @@ -21,6 +22,8 @@ import { } from "@/components/media-context-menu" import { Button } from "@/components/ui/button" import { ScrollArea } from "@/components/ui/scroll-area" +import { useCachedQuery } from "@/hooks/use-cached-query" +import { api } from "@otunes/convex/_generated/api" import { useQueueMediaActions } from "@/hooks/use-queue-media-actions" import { useTrackSelection } from "@/hooks/use-track-selection" import { cn } from "@/lib/utils" @@ -273,6 +276,20 @@ export function AlbumView({ [album.tracks] ) + // Older servers do not include album format availability yet. + const formatTracks = useCachedQuery( + api.library.getSongsForPlayback, + album.hasLossless === undefined || album.hasAtmos === undefined + ? { ids: albumSongIds } + : "skip" + ) + const hasLossless = + album.hasLossless ?? + formatTracks?.some((track) => track && "lossless" in track.files) + const hasAtmos = + album.hasAtmos ?? + formatTracks?.some((track) => track && "atmos" in track.files) + React.useEffect(() => { rememberSongs(albumDetailSongs(album)) }, [album]) @@ -372,7 +389,8 @@ export function AlbumView({ return (
- + +
@@ -392,21 +410,32 @@ export function AlbumView({

Album

-
- -

- {album.title} -

-
+

+ {album.title} +

{album.artist.name} - {metadata ? ( -

{metadata}

- ) : null} +
+ {metadata ? {metadata} : null} + {hasLossless ? ( + <> + {metadata ? · : null} + + + ) : null} + {hasAtmos ? ( + <> + {metadata || hasLossless ? ( + · + ) : null} + + + ) : null} +
diff --git a/apps/web/components/artist-view.tsx b/apps/web/components/artist-view.tsx index 785e121..a9c3fb5 100644 --- a/apps/web/components/artist-view.tsx +++ b/apps/web/components/artist-view.tsx @@ -1,6 +1,6 @@ "use client" -import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger" +import { PageHeader } from "@/components/library-skeletons" import * as React from "react" import Image from "next/image" import { Play, Shuffle } from "lucide-react" @@ -65,6 +65,7 @@ export function ArtistView({ return (
+
@@ -80,12 +81,9 @@ export function ArtistView({
-
- -

- {artist.name} -

-
+

+ {artist.name} +

-
+
{currentSong ? ( <> -
+
{currentSong.album.title}
-
- +
+ + {currentSong.title} + +

+ + {currentSong.artist.name} + + · + + {currentSong.album.title} + +

+ {currentFormat ? ( + + ) : null} ) : ( -
- oTunes -
+ oTunes )} +
+ { + setIsSeeking(true) + setSeekValue(value) + }} + onValueCommit={([value]) => { + seekTo(value) + setIsSeeking(false) + }} + aria-label="Seek" + aria-valuetext={`${formatDuration(displayTime)} of ${formatDuration(duration)}`} + /> +
-
- -
- - setVolume(value)} - aria-label="Volume" - /> -
- -
-
- -
- - {hasActiveSong ? formatDuration(displayTime) : PLACEHOLDER_TIME} - - { - setIsSeeking(true) - setSeekValue(value) - }} - onValueCommit={([value]) => { - seekTo(value) - setIsSeeking(false) - }} - aria-label="Seek" - /> - - {hasActiveSong ? formatDuration(duration) : PLACEHOLDER_TIME} - + + + + + + setVolume(value)} + aria-label="Volume" + /> + +
diff --git a/apps/web/components/playlist-view.tsx b/apps/web/components/playlist-view.tsx index 2391eb1..6dbce0c 100644 --- a/apps/web/components/playlist-view.tsx +++ b/apps/web/components/playlist-view.tsx @@ -1,6 +1,6 @@ "use client" -import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger" +import { PageHeader } from "@/components/library-skeletons" import { stationArtistId } from "@/lib/station-artist" import * as React from "react" import Image from "next/image" @@ -519,6 +519,7 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) { return (
+
@@ -545,12 +546,9 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {

Playlist

-
- -

- {playlist.title} -

-
+

+ {playlist.title} +

{playlist.owner.name}

diff --git a/apps/web/components/ui/slider.tsx b/apps/web/components/ui/slider.tsx index adb5e3f..06ecaef 100644 --- a/apps/web/components/ui/slider.tsx +++ b/apps/web/components/ui/slider.tsx @@ -49,6 +49,8 @@ function Slider({ ))} diff --git a/packages/convex/convex/library.ts b/packages/convex/convex/library.ts index 182b395..80df22b 100644 --- a/packages/convex/convex/library.ts +++ b/packages/convex/convex/library.ts @@ -538,6 +538,8 @@ export const browseAlbumDetail = query({ year: primarySong?.year ?? null, genre: primarySong?.genres[0] ?? null, releaseDate: album.date, + hasLossless: songs.some((song) => "lossless" in song.files), + hasAtmos: songs.some((song) => "atmos" in song.files), tracks: songs.map((song) => toBrowseAlbumTrack(song, artist.name)), } }, @@ -570,6 +572,8 @@ async function browseAlbumSummaryHandler( year: primarySong?.year ?? null, genre: primarySong?.genres[0] ?? null, releaseDate: album.date, + hasLossless: songs.some((song) => "lossless" in song.files), + hasAtmos: songs.some((song) => "atmos" in song.files), trackCount: songs.length, } } diff --git a/packages/convex/convex/types.ts b/packages/convex/convex/types.ts index f165925..6aee22a 100644 --- a/packages/convex/convex/types.ts +++ b/packages/convex/convex/types.ts @@ -36,6 +36,8 @@ export type BrowseAlbumDetail = BrowseAlbum & { year: number | null genre: string | null releaseDate: string + hasLossless: boolean + hasAtmos: boolean tracks: BrowseAlbumTrack[] }