fix: always restart album and playlist playback #77

Merged
joshuafhiggins merged 1 commits from t3/restart-collection-playback into main 2026-11-05 17:38:11 -05:00
2 changed files with 8 additions and 1 deletions

No files matched your search

+1
View File
@@ -859,6 +859,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
recorded.origin ??
(recorded.playlistId ? `playlist:${recorded.playlistId}` : undefined)
resetQueuePlayback()
store.update(playbackQueue.clearQueue)
store.update(recipe)
const firstSongId = store.getState().queue[0]
if (!firstSongId) return
+7 -1
View File
@@ -388,6 +388,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
const [queueOpen, setQueueOpen] = useState(false)
const [isPlaying, setIsPlaying] = useState(false)
const [playbackStartVersion, setPlaybackStartVersion] = useState(0)
const [currentTime, setCurrentTime] = useState(0)
const [measuredDuration, setMeasuredDuration] = useState<{
songId: string
@@ -890,7 +891,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
return () => {
audio.removeEventListener("canplay", onCanPlay)
}
}, [isPlaying, currentSongId, attemptPlayback])
}, [isPlaying, currentSongId, playbackStartVersion, attemptPlayback])
useEffect(() => {
const audio = audioRef.current
@@ -1069,6 +1070,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
recorded.origin ??
(recorded.playlistId ? `playlist:${recorded.playlistId}` : undefined)
const previousSongId = store.getState().queue[0]
store.update(playbackQueue.clearQueue)
store.update(recipe)
const firstSongId = store.getState().queue[0]
if (!firstSongId) {
@@ -1078,7 +1080,11 @@ export function PlaybackProvider({ children }: { children: ReactNode }) {
if (firstSongId === previousSongId) {
seekTo(0)
}
// Repeated Play/Shuffle presses must request playback even when the
// first song and playing state have not changed.
isPlayingRef.current = true
setIsPlaying(true)
setPlaybackStartVersion((version) => version + 1)
recordPlay(
recorded.playlistId
? { playlistId: recorded.playlistId }