Skip to content

claude/fix-mobile-next-track-SYq8m#14108

Open
dylanjeffers wants to merge 4 commits intomainfrom
claude/fix-mobile-next-track-SYq8m
Open

claude/fix-mobile-next-track-SYq8m#14108
dylanjeffers wants to merge 4 commits intomainfrom
claude/fix-mobile-next-track-SYq8m

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

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

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-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: c8c5bbe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@audius/mobile Patch

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

claude added 2 commits April 14, 2026 21:18
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
@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 14, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants