fix(android): sync Kotlin queue in QueuedAudioPlayer.load()#2589
Open
bitcrumb wants to merge 1 commit intodoublesymmetry:mainfrom
Open
fix(android): sync Kotlin queue in QueuedAudioPlayer.load()#2589bitcrumb wants to merge 1 commit intodoublesymmetry:mainfrom
bitcrumb wants to merge 1 commit intodoublesymmetry:mainfrom
Conversation
In the else branch of load(), ExoPlayer's media items were replaced but the internal Kotlin queue LinkedList was never updated. This caused queue[currentIndex] to always return the first-ever loaded item, so updateMetadataForTrack would resolve to the wrong track and call replaceItem() with a stale stream URL — reverting the current station back to the original within ~10 seconds of switching. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Closed
Author
Question: could
|
Author
|
Just noticed that this issue is talking about the same thing: #2587 |
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.
Summary
In the
elsebranch ofQueuedAudioPlayer.load(), ExoPlayer's internal playlist was updated (viaaddMediaItem+removeMediaItem) but the KotlinqueueLinkedList was never updated to match. This causedqueue[currentIndex]to always return the first-ever loaded item after switching tracks.The immediate symptom:
updateMetadataForTrack(index, bundle)reads the current track fromqueue[index], then callsreplaceItem(index, track.toAudioItem()). Becausequeue[0]still pointed to the original track,replaceItemwould callexoPlayer.replaceMediaItemwith the original stream URL — reverting playback to the first-ever loaded track within ~10 seconds of switching (the metadata refresh interval).Root cause
load()in the non-empty queue case bypassesadd()and manipulates ExoPlayer directly, but forgot to mirror the change to the Kotlinqueue:All properties that read from the queue (
currentItem,items,previousItems,nextItems) and any caller that usesqueue[index]directly (e.g.replaceItem) receive stale data afterload().Fix
Materialise the
MediaItemonce and assign it toqueue[currentIndex]before passing it to ExoPlayer: