Open
Conversation
When pressing next/previous in the now playing drawer, the queue index was updated by the reducer before the PlaybackActiveTrackChanged event fired. This meant playerIndex === queueIndex, causing the event handler to skip the player state update. The player state then relied entirely on the saga chain, which goes through a web audio shim (no-op on mobile) and could fail to dispatch playSucceeded. Two changes: - In AudioPlayer, handle the manual skip case (playerIndex === queueIndex) in the PlaybackActiveTrackChanged handler by updating player info directly when the active track UID differs from the player UID - In NowPlayingDrawer, remove redundant setMediaKey calls from onNext and onPrevious since the useEffect watching playCounter/currentUid already handles this, preventing a double-bump https://claude.ai/code/session_01RiJBWs7WdMdhPvDmfNDtnh
🦋 Changeset detectedLatest commit: c8c5bbe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
handleQueueChange's non-append path awaited reset/play/add BEFORE assigning enqueueTracksJobRef.current, leaving a window where the ref was undefined while the queue was still being built. If the user pressed next in that window, handleQueueIdxChange's await on the ref resolved immediately and the subsequent skip was silently dropped because queueIndex was past the (still empty) RNTP queue length. Wrap the full setup (reset, play, first track load, middle-out enqueue) in a single promise and assign it to enqueueTracksJobRef before any awaits, so handleQueueIdxChange correctly defers the skip until the queue is ready. https://claude.ai/code/session_01RiJBWs7WdMdhPvDmfNDtnh
TrackPlayer.skip() in RNTP v4 doesn't reliably continue playback when called shortly after queue manipulation - it can leave the player in a Ready state instead of Playing, which is exactly what happens when handleQueueIdxChange skips to the new track right after the initial queue has been built. The drawer shows the new track (from the saga's playSucceeded) but the audio keeps playing the old track because the skip did not resume playback. Explicitly call TrackPlayer.play() after skip() to force playback. This is the audio-switch the saga chain cannot do on mobile, since the web audioPlayer is a no-op shim there. Also wrap the setupPromise body in try/catch so a failing RNTP call doesn't leave enqueueTracksJobRef holding a rejected promise, which would make subsequent awaits in handleQueueIdxChange throw silently. https://claude.ai/code/session_01RiJBWs7WdMdhPvDmfNDtnh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When pressing next/previous in the now playing drawer, the queue index
was updated by the reducer before the PlaybackActiveTrackChanged event
fired. This meant playerIndex === queueIndex, causing the event handler
to skip the player state update. The player state then relied entirely
on the saga chain, which goes through a web audio shim (no-op on mobile)
and could fail to dispatch playSucceeded.
Two changes:
in the PlaybackActiveTrackChanged handler by updating player info
directly when the active track UID differs from the player UID
and onPrevious since the useEffect watching playCounter/currentUid
already handles this, preventing a double-bump
https://claude.ai/code/session_01RiJBWs7WdMdhPvDmfNDtnh