From a08a4956c90fc4b48528e3d6a6654fc62c7a5daf Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Sun, 15 Nov 2026 16:09:20 -0500 Subject: [PATCH] fix(playback): pause and replay the final queue track --- apps/mobile/contexts/playback.tsx | 14 +++++++++++--- apps/web/components/playback-provider.tsx | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/mobile/contexts/playback.tsx b/apps/mobile/contexts/playback.tsx index 96241e8..8980e63 100644 --- a/apps/mobile/contexts/playback.tsx +++ b/apps/mobile/contexts/playback.tsx @@ -376,7 +376,8 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { const handlePlaylistStatusUpdate = useCallback( (status: AudioPlaylistStatus) => { - if (!status.isLoaded) return + // iOS may remove the finished item before delivering its final status. + if (!status.isLoaded && !status.didJustFinish) return const state = storeRef.current.getState() if (loadedSongIdsRef.current[status.currentIndex] !== state.queue[0]) { return @@ -427,7 +428,14 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { isPlayingRef.current = false setIsPlayingState(false) storeRef.current.update(playbackQueue.skipNext) - void playlistRef.current?.seekTo(0) + const playlist = playlistRef.current + if (playlist) { + playlist.pause() + // Reload the final item, which iOS removes when playback ends. + ignoreTrackChangeRef.current = true + playlist.skipTo(status.currentIndex) + scheduleTrackChangeHandling() + } currentTimeRef.current = 0 setCurrentTime(0) return @@ -443,7 +451,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { playlist?.play() } }, - [] + [scheduleTrackChangeHandling] ) const handleTrackChanged = useCallback( diff --git a/apps/web/components/playback-provider.tsx b/apps/web/components/playback-provider.tsx index 524a611..99471b7 100644 --- a/apps/web/components/playback-provider.tsx +++ b/apps/web/components/playback-provider.tsx @@ -955,6 +955,7 @@ export function PlaybackProvider({ children }: { children: ReactNode }) { if (!shouldContinuePlaying) { autoPlayNextRef.current = false isPlayingRef.current = false + audio.pause() audio.currentTime = 0 currentTimeRef.current = 0 setCurrentTime(0) -- 2.54.1