feat: show album audio formats and refresh the web player
This commit is contained in:
1 parent
ebcf64253e
commit
ebefd1ddbd
8 files changed
+308
-98
No files matched your search
@@ -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 {
|
||||
@@ -218,11 +219,49 @@ export default function AlbumScreen() {
|
||||
{album.artist.name}
|
||||
</Text>
|
||||
</Pressable>
|
||||
{metadata ? (
|
||||
<Text style={{ color: palette.secondaryForeground }}>
|
||||
{metadata}
|
||||
</Text>
|
||||
) : null}
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
flexWrap: "wrap",
|
||||
gap: 8,
|
||||
}}
|
||||
>
|
||||
{metadata ? (
|
||||
<Text style={{ color: palette.secondaryForeground }}>
|
||||
{metadata}
|
||||
</Text>
|
||||
) : null}
|
||||
{album.hasLossless ? (
|
||||
<>
|
||||
{metadata ? (
|
||||
<Text style={{ color: palette.secondaryForeground }}>
|
||||
·
|
||||
</Text>
|
||||
) : null}
|
||||
<AudioFormatBadge
|
||||
format="lossless"
|
||||
color={palette.secondaryForeground}
|
||||
backgroundColor={palette.background}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
{album.hasAtmos ? (
|
||||
<>
|
||||
{metadata || album.hasLossless ? (
|
||||
<Text style={{ color: palette.secondaryForeground }}>
|
||||
·
|
||||
</Text>
|
||||
) : null}
|
||||
<AudioFormatBadge
|
||||
format="atmos"
|
||||
color={palette.secondaryForeground}
|
||||
backgroundColor={palette.background}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</View>
|
||||
<View style={styles.actions}>
|
||||
<Pressable
|
||||
onPress={() => void toggleAlbumFavorite(album.id)}
|
||||
|
||||
@@ -6,6 +6,7 @@ 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"
|
||||
|
||||
@@ -404,9 +405,23 @@ export function AlbumView({
|
||||
>
|
||||
{album.artist.name}
|
||||
</Link>
|
||||
{metadata ? (
|
||||
<p className="text-sm text-muted-foreground">{metadata}</p>
|
||||
) : null}
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start">
|
||||
{metadata ? <span>{metadata}</span> : null}
|
||||
{album.hasLossless ? (
|
||||
<>
|
||||
{metadata ? <span aria-hidden>·</span> : null}
|
||||
<AudioFormatBadge format="lossless" />
|
||||
</>
|
||||
) : null}
|
||||
{album.hasAtmos ? (
|
||||
<>
|
||||
{metadata || album.hasLossless ? (
|
||||
<span aria-hidden>·</span>
|
||||
) : null}
|
||||
<AudioFormatBadge format="atmos" />
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 sm:justify-start">
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import type { PlaybackFormat } from "@otunes/convex/playback-stream"
|
||||
|
||||
const MARK_HEIGHT = 11
|
||||
|
||||
function DolbyMark({ color }: { color: string }) {
|
||||
return (
|
||||
<svg
|
||||
width={(MARK_HEIGHT * 23) / 16}
|
||||
height={MARK_HEIGHT}
|
||||
viewBox="0 0 23 16"
|
||||
>
|
||||
<path d="M0 0H2.5A8 8 0 0 1 2.5 16H0Z" fill={color} />
|
||||
<path d="M23 0H20.5A8 8 0 0 0 20.5 16H23Z" fill={color} />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
const LOSSLESS_PEAKS = [110, 215, 320]
|
||||
const LOSSLESS_THIN_WIDTH = 24
|
||||
const LOSSLESS_STROKES: [peak: number, d: string][] = [
|
||||
[110, "M-70 320C-62 245 -38 166 0 166"],
|
||||
[215, "M-70 320C-62 245 -38 166 0 166"],
|
||||
[320, "M-30 185C-22 173 -11 166 0 166"],
|
||||
[110, "M166 413C176 413 186 406 194 395"],
|
||||
[215, "M166 413C200 413 226 340 240 275"],
|
||||
[320, "M166 413C200 413 226 340 240 275"],
|
||||
]
|
||||
const LOSSLESS_FALL =
|
||||
"M0 178L4 179L8 181L12 184L16 189L20 196L23 204L27 213L30 223L34 233L39 243L43 254L48 266L53 278L58 289L62 301L66 313L71 325L75 336L79 347L83 357L86 364L89 370L93 377L97 382L101 387L105 392L109 397L113 401L117 405L121 408L126 412L130 415L134 417L139 419L143 421L148 423L152 424L157 424L161 425L166 425L166 401L163 401L161 400L159 400L157 399L154 397L152 396L151 394L149 392L147 389L145 386L143 383L142 380L140 376L138 371L137 367L135 362L134 357L132 351L130 345L127 339L124 330L120 319L116 308L111 297L107 285L102 272L98 260L93 248L88 235L82 223L76 212L69 201L61 192L53 183L45 175L37 168L28 163L19 158L10 155L0 154Z"
|
||||
const LOSSLESS_FALL_GAP =
|
||||
"M0 178L4 180L6 184L8 190L9 197L11 203L14 210L17 219L21 228L24 238L29 248L33 259L38 270L43 282L47 293L52 305L56 317L60 328L64 340L68 351L73 361L76 368L79 375L83 381L87 387L91 393L95 398L100 403L104 408L109 412L113 416L118 419L124 422L130 424L135 425L141 426L147 426L152 426L157 425L161 425L166 425L166 401L163 401L161 399L159 398L158 395L157 393L156 390L155 387L155 384L154 381L153 379L152 376L150 373L149 369L148 366L146 361L145 357L143 352L142 347L140 341L137 335L134 326L130 315L126 304L122 293L117 281L113 268L108 256L103 243L98 231L92 219L86 207L79 196L71 186L62 177L53 168L44 161L32 157L21 155L10 154L0 154Z"
|
||||
|
||||
/**
|
||||
* Three overlapping waves. Each thick downstroke is outlined in the
|
||||
* background color so it reads as passing over the strokes behind it.
|
||||
*/
|
||||
function LosslessMark({
|
||||
color,
|
||||
backgroundColor,
|
||||
}: {
|
||||
color: string
|
||||
backgroundColor: string
|
||||
}) {
|
||||
return (
|
||||
<svg
|
||||
width={(MARK_HEIGHT * 544) / 271}
|
||||
height={MARK_HEIGHT}
|
||||
viewBox="28 154 544 271"
|
||||
>
|
||||
{LOSSLESS_STROKES.map(([peak, d], index) => (
|
||||
<path
|
||||
key={index}
|
||||
d={d}
|
||||
transform={`translate(${peak})`}
|
||||
stroke={color}
|
||||
strokeWidth={LOSSLESS_THIN_WIDTH}
|
||||
strokeLinecap="round"
|
||||
fill="none"
|
||||
/>
|
||||
))}
|
||||
{LOSSLESS_PEAKS.map((peak) => (
|
||||
<g key={peak} transform={`translate(${peak})`}>
|
||||
<path d={LOSSLESS_FALL_GAP} fill={backgroundColor} />
|
||||
<path d={LOSSLESS_FALL} fill={color} />
|
||||
</g>
|
||||
))}
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export function AudioFormatBadge({
|
||||
format,
|
||||
iconOnly = false,
|
||||
backgroundColor = "var(--background)",
|
||||
}: {
|
||||
format: PlaybackFormat
|
||||
iconOnly?: boolean
|
||||
backgroundColor?: string
|
||||
}) {
|
||||
const label = format === "atmos" ? "Dolby Atmos" : "Lossless"
|
||||
return (
|
||||
<span
|
||||
className="inline-flex shrink-0 items-center gap-[3px] text-[13px] font-medium"
|
||||
title={iconOnly ? label : undefined}
|
||||
>
|
||||
<span aria-hidden="true">
|
||||
{format === "atmos" ? (
|
||||
<DolbyMark color="currentColor" />
|
||||
) : (
|
||||
<LosslessMark
|
||||
color="currentColor"
|
||||
backgroundColor={backgroundColor}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
<span className={iconOnly ? "sr-only" : undefined}>{label}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -19,7 +19,11 @@ import { toast } from "sonner"
|
||||
import { api } from "@otunes/convex/_generated/api"
|
||||
import type { Id } from "@otunes/convex/_generated/dataModel"
|
||||
import type { BrowseSong } from "@otunes/convex/types"
|
||||
import { playbackStreamPlan } from "@otunes/convex/playback-stream"
|
||||
import {
|
||||
playbackFormat,
|
||||
type PlaybackFormat,
|
||||
playbackStreamPlan,
|
||||
} from "@otunes/convex/playback-stream"
|
||||
import {
|
||||
ANONYMOUS_CACHE_SCOPE,
|
||||
useCacheScope,
|
||||
@@ -44,6 +48,7 @@ const PROGRESS_SAVE_INTERVAL_MS = 5000
|
||||
type PlaybackContextValue = {
|
||||
queueSongIds: Id<"songs">[]
|
||||
queueHistorySongIds: Id<"songs">[]
|
||||
currentFormat: PlaybackFormat | null
|
||||
currentSong: BrowseSong | null
|
||||
shuffleEnabled: boolean
|
||||
repeatEnabled: RepeatMode
|
||||
@@ -1321,11 +1326,21 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
skipPrevious,
|
||||
})
|
||||
|
||||
const currentFormat =
|
||||
currentSongDoc && user
|
||||
? playbackFormat(
|
||||
currentSongDoc.files,
|
||||
user.playbackQuality,
|
||||
dolbyAtmosSupported === true && (user.preferAtmos ?? false)
|
||||
)
|
||||
: null
|
||||
|
||||
const value = useMemo<PlaybackContextValue>(
|
||||
() => ({
|
||||
queueSongIds: playback.queue,
|
||||
queueHistorySongIds: playback.history,
|
||||
currentSong,
|
||||
currentFormat,
|
||||
shuffleEnabled: playback.shuffleEnabled,
|
||||
repeatEnabled: playback.repeatEnabled,
|
||||
queueOpen,
|
||||
@@ -1359,6 +1374,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
|
||||
[
|
||||
playback,
|
||||
currentSong,
|
||||
currentFormat,
|
||||
queueOpen,
|
||||
isPlaybackActive,
|
||||
volume,
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
import * as React from "react"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
import {
|
||||
ListMusic,
|
||||
Music,
|
||||
MessageSquareQuote,
|
||||
Pause,
|
||||
Play,
|
||||
Repeat,
|
||||
@@ -15,7 +16,12 @@ import {
|
||||
Volume2,
|
||||
} from "lucide-react"
|
||||
|
||||
import { PlaybackSongMeta } from "@/components/playback-song-meta"
|
||||
import { AudioFormatBadge } from "@/components/audio-format-badge"
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover"
|
||||
import {
|
||||
usePlayback,
|
||||
usePlaybackProgress,
|
||||
@@ -26,8 +32,6 @@ import { useSidebar } from "@/components/ui/sidebar"
|
||||
import { albumCoverUrl } from "@/lib/cover-urls"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const PLACEHOLDER_TIME = "--:--"
|
||||
|
||||
function formatDuration(seconds: number): string {
|
||||
const total = Math.max(0, Math.floor(seconds))
|
||||
const minutes = Math.floor(total / 60)
|
||||
@@ -38,6 +42,7 @@ function formatDuration(seconds: number): string {
|
||||
export function PlayerBar() {
|
||||
const {
|
||||
currentSong,
|
||||
currentFormat,
|
||||
shuffleEnabled,
|
||||
repeatEnabled,
|
||||
queueOpen,
|
||||
@@ -66,23 +71,25 @@ export function PlayerBar() {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"pointer-events-none fixed bottom-4 z-50 flex justify-center px-4 transition-[left,right] duration-200 ease-linear",
|
||||
sidebarExpanded ? "left-[16rem] right-0" : "inset-x-0",
|
||||
"@container pointer-events-none fixed bottom-4 z-50 flex justify-center px-4 transition-[left,right] duration-200 ease-linear",
|
||||
sidebarExpanded ? "right-0 left-[16rem]" : "inset-x-0",
|
||||
queueOpen && !isMobile && "right-72"
|
||||
)}
|
||||
>
|
||||
<div className="pointer-events-auto flex w-full max-w-3xl flex-col gap-2 rounded-xl border bg-card/80 px-3 py-2 shadow-lg backdrop-blur">
|
||||
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2">
|
||||
<div className="flex items-center justify-start gap-1">
|
||||
<div className="pointer-events-auto flex w-full max-w-6xl items-center gap-2 rounded-full border border-white/20 bg-[#303033] px-3 py-2 text-white shadow-lg @min-[640px]:gap-5 @min-[640px]:px-5 @min-[640px]:py-3">
|
||||
<div className="flex shrink-0 items-center gap-0 @min-[640px]:gap-1 [&_button]:size-7 @min-[640px]:[&_button]:size-10 [&_svg]:size-4 @min-[640px]:[&_svg]:size-6">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="Shuffle"
|
||||
aria-pressed={shuffleEnabled}
|
||||
className={cn(shuffleEnabled && "text-primary")}
|
||||
className={cn(
|
||||
"hidden @min-[640px]:inline-flex",
|
||||
shuffleEnabled ? "text-white" : "text-white/40"
|
||||
)}
|
||||
onClick={() => void toggleShuffle()}
|
||||
>
|
||||
<Shuffle />
|
||||
<Shuffle className="size-4 @min-[640px]:size-6" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -91,7 +98,7 @@ export function PlayerBar() {
|
||||
disabled={!hasQueue}
|
||||
onClick={() => void skipPrevious()}
|
||||
>
|
||||
<SkipBack />
|
||||
<SkipBack className="size-4 fill-current @min-[640px]:size-6" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -100,7 +107,11 @@ export function PlayerBar() {
|
||||
disabled={!hasQueue}
|
||||
onClick={() => setIsPlaying(!isPlaying)}
|
||||
>
|
||||
{isPlaying ? <Pause /> : <Play className="fill-current" />}
|
||||
{isPlaying ? (
|
||||
<Pause className="size-5! fill-current @min-[640px]:size-8!" />
|
||||
) : (
|
||||
<Play className="size-5! fill-current @min-[640px]:size-8!" />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -109,52 +120,113 @@ export function PlayerBar() {
|
||||
disabled={!hasQueue}
|
||||
onClick={() => void skipNext()}
|
||||
>
|
||||
<SkipForward />
|
||||
<SkipForward className="size-4 fill-current @min-[640px]:size-6" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="Repeat"
|
||||
aria-pressed={repeatEnabled !== "none"}
|
||||
className={cn(repeatEnabled !== "none" && "text-primary")}
|
||||
className={cn(
|
||||
"hidden @min-[640px]:inline-flex",
|
||||
repeatEnabled !== "none" ? "text-white" : "text-white/40"
|
||||
)}
|
||||
onClick={() => void cycleRepeat()}
|
||||
>
|
||||
{repeatEnabled === "once" ? <Repeat1 /> : <Repeat />}
|
||||
{repeatEnabled === "once" ? (
|
||||
<Repeat1 className="size-4 @min-[640px]:size-6" />
|
||||
) : (
|
||||
<Repeat className="size-4 @min-[640px]:size-6" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex h-10 min-w-0 items-center justify-center gap-3 px-2">
|
||||
<div className="relative flex min-w-0 flex-1 items-center gap-2 pb-2 @min-[640px]:gap-3">
|
||||
{currentSong ? (
|
||||
<>
|
||||
<div className="relative size-8 shrink-0 overflow-hidden rounded">
|
||||
<div className="relative size-9 shrink-0 overflow-hidden rounded @min-[640px]:size-14">
|
||||
<Image
|
||||
src={albumCoverUrl(currentSong.album.id)}
|
||||
alt={currentSong.album.title}
|
||||
fill
|
||||
sizes="32px"
|
||||
sizes="56px"
|
||||
className="object-cover"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex h-10 min-w-0 max-w-48 flex-col justify-center overflow-hidden sm:max-w-64">
|
||||
<PlaybackSongMeta song={currentSong} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<Link
|
||||
href={`/album/${currentSong.album.id}`}
|
||||
className="block truncate text-sm font-semibold hover:underline @min-[640px]:text-xl"
|
||||
>
|
||||
{currentSong.title}
|
||||
</Link>
|
||||
<p className="truncate text-xs @min-[640px]:text-lg">
|
||||
<Link
|
||||
href={`/artist/${currentSong.artist.id}`}
|
||||
className="hover:underline"
|
||||
>
|
||||
{currentSong.artist.name}
|
||||
</Link>
|
||||
<span aria-hidden> · </span>
|
||||
<Link
|
||||
href={`/album/${currentSong.album.id}`}
|
||||
className="hover:underline"
|
||||
>
|
||||
{currentSong.album.title}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
{currentFormat ? (
|
||||
<AudioFormatBadge
|
||||
format={currentFormat}
|
||||
iconOnly
|
||||
backgroundColor="#303033"
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
) : (
|
||||
<div className="flex size-8 shrink-0 items-center justify-center">
|
||||
<Image
|
||||
src="/logo-monochrome.svg"
|
||||
alt="oTunes"
|
||||
width={14}
|
||||
height={24}
|
||||
className="h-6 w-auto opacity-85"
|
||||
/>
|
||||
</div>
|
||||
<Image
|
||||
src="/logo-monochrome.svg"
|
||||
alt="oTunes"
|
||||
width={14}
|
||||
height={24}
|
||||
className="mx-auto my-2 h-6 w-auto opacity-85"
|
||||
/>
|
||||
)}
|
||||
<div className="absolute inset-x-0 -bottom-1">
|
||||
<Slider
|
||||
className={cn(
|
||||
"h-3 flex-1 [&_[data-slot=slider-range]]:bg-white/80 [&_[data-slot=slider-thumb]]:size-2 [&_[data-slot=slider-thumb]]:opacity-0 focus-within:[&_[data-slot=slider-thumb]]:opacity-100 hover:[&_[data-slot=slider-thumb]]:opacity-100 [&_[data-slot=slider-track]]:h-[3px] [&_[data-slot=slider-track]]:bg-white/30",
|
||||
!hasActiveSong && "[&_[data-slot=slider-thumb]]:hidden"
|
||||
)}
|
||||
min={0}
|
||||
max={maxDuration}
|
||||
step={0.1}
|
||||
value={[displayTime]}
|
||||
disabled={!hasActiveSong}
|
||||
onValueChange={([value]) => {
|
||||
setIsSeeking(true)
|
||||
setSeekValue(value)
|
||||
}}
|
||||
onValueCommit={([value]) => {
|
||||
seekTo(value)
|
||||
setIsSeeking(false)
|
||||
}}
|
||||
aria-label="Seek"
|
||||
aria-valuetext={`${formatDuration(displayTime)} of ${formatDuration(duration)}`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-end gap-1">
|
||||
<Button variant="ghost" size="icon" aria-label="Lyrics" disabled>
|
||||
<Music />
|
||||
<div className="flex shrink-0 items-center gap-0 @min-[640px]:gap-2 [&_button]:size-7 @min-[640px]:[&_button]:size-10 [&_svg]:size-4 @min-[640px]:[&_svg]:size-6">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="hidden @min-[640px]:inline-flex"
|
||||
aria-label="Lyrics"
|
||||
disabled
|
||||
>
|
||||
<MessageSquareQuote className="size-4 @min-[640px]:size-6" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -164,63 +236,24 @@ export function PlayerBar() {
|
||||
className={cn(queueOpen && "text-primary")}
|
||||
onClick={toggleQueueOpen}
|
||||
>
|
||||
<ListMusic />
|
||||
<ListMusic className="size-4 @min-[640px]:size-6" />
|
||||
</Button>
|
||||
<div className="hidden items-center gap-2 sm:flex">
|
||||
<Volume2 className="size-4 shrink-0 text-muted-foreground" />
|
||||
<Slider
|
||||
className="w-20"
|
||||
min={0}
|
||||
max={100}
|
||||
value={[volume]}
|
||||
onValueChange={([value]) => setVolume(value)}
|
||||
aria-label="Volume"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="Volume"
|
||||
className="sm:hidden"
|
||||
>
|
||||
<Volume2 />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 px-1">
|
||||
<span
|
||||
className="w-9 shrink-0 text-right text-xs tabular-nums text-muted-foreground"
|
||||
aria-hidden
|
||||
>
|
||||
{hasActiveSong ? formatDuration(displayTime) : PLACEHOLDER_TIME}
|
||||
</span>
|
||||
<Slider
|
||||
className={cn(
|
||||
"flex-1",
|
||||
!hasActiveSong && "[&_[data-slot=slider-thumb]]:hidden"
|
||||
)}
|
||||
min={0}
|
||||
max={maxDuration}
|
||||
step={0.1}
|
||||
value={[displayTime]}
|
||||
disabled={!hasActiveSong}
|
||||
onValueChange={([value]) => {
|
||||
setIsSeeking(true)
|
||||
setSeekValue(value)
|
||||
}}
|
||||
onValueCommit={([value]) => {
|
||||
seekTo(value)
|
||||
setIsSeeking(false)
|
||||
}}
|
||||
aria-label="Seek"
|
||||
/>
|
||||
<span
|
||||
className="w-9 shrink-0 text-xs tabular-nums text-muted-foreground"
|
||||
aria-hidden
|
||||
>
|
||||
{hasActiveSong ? formatDuration(duration) : PLACEHOLDER_TIME}
|
||||
</span>
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button variant="ghost" size="icon" aria-label="Volume">
|
||||
<Volume2 className="size-4 @min-[640px]:size-6" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent side="top" align="end" className="w-40">
|
||||
<Slider
|
||||
min={0}
|
||||
max={100}
|
||||
value={[volume]}
|
||||
onValueChange={([value]) => setVolume(value)}
|
||||
aria-label="Volume"
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -49,6 +49,8 @@ function Slider({
|
||||
<SliderPrimitive.Thumb
|
||||
data-slot="slider-thumb"
|
||||
key={index}
|
||||
aria-label={props["aria-label"]}
|
||||
aria-valuetext={props["aria-valuetext"]}
|
||||
className="relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ export type BrowseAlbumDetail = BrowseAlbum & {
|
||||
year: number | null
|
||||
genre: string | null
|
||||
releaseDate: string
|
||||
hasLossless: boolean
|
||||
hasAtmos: boolean
|
||||
tracks: BrowseAlbumTrack[]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user