diff --git a/app/components/mini-player.tsx b/app/components/mini-player.tsx index 55963dd..033e71a 100644 --- a/app/components/mini-player.tsx +++ b/app/components/mini-player.tsx @@ -12,6 +12,7 @@ export function MiniPlayer({ repeatLabel, repeating, onRepeat, + seek, children, }: { label: string; @@ -20,8 +21,6 @@ export function MiniPlayer({ title: string; details: string; href: string; - /** Names the page the artwork link opens. */ - page: string; artwork?: string; }; controls?: boolean; @@ -30,6 +29,7 @@ export function MiniPlayer({ repeatLabel: string; repeating: boolean; onRepeat: (repeat: boolean) => void; + seek?: ReactNode; children?: ReactNode; }) { return ( @@ -37,44 +37,39 @@ export function MiniPlayer({ className={className ? `release-mini ${className}` : "release-mini"} aria-label={label} > + {(controls || track?.artwork) && ( +
+ {track?.artwork && ( + + )} + {controls && ( + + )} +
+ )} {track && ( - <> - - {track.artwork ? ( - - ) : ( - - )} - -
- {track.title} - {track.details} -
- +
+ {track.title} + {track.details} +
)} + {seek} {controls && ( - <> - - onRepeat(!repeating)} - /> - + onRepeat(!repeating)} + /> )} {children} diff --git a/app/components/release-player.tsx b/app/components/release-player.tsx index 24dcdfb..3e88741 100644 --- a/app/components/release-player.tsx +++ b/app/components/release-player.tsx @@ -12,6 +12,7 @@ import { useMediaSession } from "./media-session"; import { setRepeatPreference, useRepeatPreference } from "./repeat-preference"; import { BufferedAudio } from "./buffered-audio"; import { MiniPlayer } from "./mini-player"; +import { ReleaseSeek } from "./release-seek"; import { useSpaceToggle } from "./use-space-toggle"; const PlaybackContext = createContext(null); @@ -39,8 +40,17 @@ export function ReleasePlayerProvider({ children }: { children: ReactNode }) { } function ReleasePlayer() { - const { playback, queue, index, status, error, seeking, media } = - useReleasePlayer(); + const { + playback, + queue, + index, + status, + error, + seeking, + media, + position, + duration, + } = useReleasePlayer(); const repeat = useRepeatPreference(); useEffect(() => { playback.setRepeat(repeat); @@ -81,7 +91,6 @@ function ReleasePlayer() { title: track.title, details: track.artist, href: queue.url, - page: queue.title, artwork: queue.artwork?.src, } : undefined @@ -91,6 +100,16 @@ function ReleasePlayer() { repeatLabel="Repeat track" repeating={repeat} onRepeat={setRepeatPreference} + seek={ + track && ( + + ) + } > {track && ( <> diff --git a/app/components/release-seek.tsx b/app/components/release-seek.tsx index 2f74b6e..fa88000 100644 --- a/app/components/release-seek.tsx +++ b/app/components/release-seek.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState, type CSSProperties } from "react"; import { formatClock } from "../domain/format"; export function ReleaseSeek({ @@ -13,6 +13,8 @@ export function ReleaseSeek({ const [preview, setPreview] = useState(null); const input = useRef(null); const pending = useRef(null); + const elapsedTime = formatClock(preview ?? position); + const totalTime = formatClock(duration); function cancel() { pending.current = null; setPreview(null); @@ -41,15 +43,27 @@ export function ReleaseSeek({ }, [onSeek]); return (