Fix episode resuming from the beginning after switching playback (issue #287) - #288
Merged
Merged
Conversation
Switching to a different episode never explicitly saved the outgoing episode's position -- the only other writers of enclosurePosition (PlaybackService's periodic save loop and its on-pause save) act on player.currentMediaItem, which by the time either fires typically already reflects the new episode, since the switch's own setMediaItem call updates it synchronously before the listener callback runs. The outgoing episode's progress was lost, so Next Up auto-advancing back to it later restarted from the beginning instead of resuming.
The lookahead window's seamless Timeline auto-transition (issue #256's common advance path) never applied a resumed episode's saved position: START_POSITION_MS_EXTRA_KEY is a custom extra baked into each resolved MediaItem's metadata, and ExoPlayer's Timeline has no native concept of a per-item start position, so a native auto-transition just played the new current item from its own natural start (0). Only playNextQueued's manual fallback path (used when nothing was pre-materialized) actually seeked/set with that position. Combined with the previous commit's fix (which ensured a switched-away-from episode's position was actually saved at all), this closes the "resumed from the beginning" bug.
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
PlaybackControllernever explicitly saved the outgoing episode's position when switching to a different one -- the only other writers ofenclosurePositionact on whateverplayer.currentMediaItemis at call time, which by then usually already reflects the new episode.START_POSITION_MS_EXTRA_KEYis a custom extra with no native ExoPlayer meaning, so a native auto-transition just played the new item from position 0. Only the manualplayNextQueuedfallback path actually seeked to it.Test plan
./gradlew assembleDebug testDebugUnitTest lintDebug-- all pass, including two newPlaybackControllerTestregression tests.