diff --git a/src/app/music/_components/AudioPlayer.tsx b/src/app/music/_components/AudioPlayer.tsx index bfc25d2..dc1eee1 100644 --- a/src/app/music/_components/AudioPlayer.tsx +++ b/src/app/music/_components/AudioPlayer.tsx @@ -47,7 +47,15 @@ export default function AudioPlayer(props: { const [downloading, setDownloading] = useState(false); const { resolvedTheme } = useTheme(); - const { currentId, isPlaying, currentTime, toggle, seek, subscribeTime } = useMusicPlayer(); + const { + currentId, + isPlaying, + currentTime, + duration: engineDuration, + toggle, + seek, + subscribeTime, + } = useMusicPlayer(); const isActive = currentId === props.id; // Reach live values from the once-created wavesurfer callbacks. @@ -143,6 +151,9 @@ export default function AudioPlayer(props: { } const playing = isActive && isPlaying; + // The waveform is only a visual; playback is owned by the shared engine. Show + // its duration if the waveform hasn't decoded (slow/unreliable on mobile). + const shownDuration = duration || (isActive ? engineDuration : 0); return (
@@ -151,7 +162,6 @@ export default function AudioPlayer(props: { size="icon" variant="ghost" aria-label={playing ? "Pause" : "Play"} - disabled={!ready} onClick={() => toggle(props.id)} > {playing ? : } @@ -171,7 +181,7 @@ export default function AudioPlayer(props: {
- {formatTime(duration)} + {formatTime(shownDuration)}