/** The full-screen now-playing view. */ import type { Album, PlayerState } from "../api/types"; import { usePlaybackClock } from "../hooks/usePlaybackClock"; import { isBook, nowPlayingText } from "../lib/covers"; import { clock, remainingInAlbum } from "../lib/format"; import { groupOf } from "../lib/search"; import { SHOW_DECORATIVE_ANIMATIONS } from "../lib/theme"; import { Cover } from "./Cover"; import { ProgressBar } from "./ProgressBar"; import { Transport } from "./Transport"; import { VolumeBars } from "./VolumeBars"; interface Props { state: PlayerState; album: Album | null; onToggle: () => void; onNext: () => void; onPrevious: () => void; onSeek: (position: number) => void; onVolume: (percent: number) => void; onMute: () => void; onOpenAlbum: () => void; /** Assigning the current album/show to a remote key. `assignPending` is true right * after "A" is pressed, waiting for the digit that completes the shortcut. */ onOpenAssign: () => void; assignPending: boolean; } export function PlayView({ state, album, onToggle, onNext, onPrevious, onSeek, onVolume, onMute, onOpenAlbum, onOpenAssign, assignPending, }: Props) { const position = usePlaybackClock(state.position, state.playing); const now = nowPlayingText(state, album); const book = album ? isBook(album) : false; const podcast = album ? groupOf(album) === "podcasts" : false; const remaining = album ? remainingInAlbum( album.tracks.map((track) => track.duration), state.track_index, position, ) : 0; return (
{album ? ( ) : (
)}
{now.title}
{now.subtitle}
{album && (
{now.progress}
)}
{state.duration ? `−${clock(state.duration - position)}` : ""} {album && !podcast ? `Noch ${clock(remaining)} ${book ? "im Hörbuch" : "im Album"}` : ""}
{album && ( )}
); }