Fixed resuming streams at the last playback position#13195
Fixed resuming streams at the last playback position#13195TobiGr merged 4 commits intoTeamNewPipe:devfrom
Conversation
…overy position that was set in Player.handleIntent for RESUME_PLAYBACK when resuming playback
128eff8 to
118def0
Compare
TobiGr
left a comment
There was a problem hiding this comment.
Thank you for looking into it. I just don't quite understand the changes on why the recovery position is set twice in the code.
| setRecovery(); // making sure to save playback position before reloadPlayQueueManager() | ||
| if (hasTimeline || !hasPendingRecovery) { | ||
| // making sure to save playback position before reloadPlayQueueManager() | ||
| setRecovery(); | ||
| } |
There was a problem hiding this comment.
The if conditions I added are supposed to ensure
setRecoveryis only called when there is no pending recovery (it won't be overwriting a recovery position that's already been set), or when exoplayer is far along in it's setup so that there's stuff to play (timeline is not empty).
Hm, setRecovery() is called anyway here, independently from whether a recovery position was already set or not.. Don't you need to remove the first call? This is at least what I understood from your detailed explanation.
There was a problem hiding this comment.
Lmao my bad, this a git issue, seems the rebasing I did onto dev didn't actually end up as it showed in Android Studio. Above setRecovery is not supposed to be there x).
I've confirmed this doesn't actually work with the above setRecovery still in place. I've removed it now
TobiGr
left a comment
There was a problem hiding this comment.
thanks. I think we should create a hotfix 0.28.4 out of this.
|
/backport release-0.28.3 |
|
Successfully created backport PR for |
What is it?
refactorbranchDescription of the changes in your PR
Reason for the bug is that 1d8ea01 adds a call to
useVideoAndSubtitlesin theinitPlaybackoverrides in the UI classes. This causes the recovery position for the queue item to be overridden due to the following flow:Player.handleIntentis calledif (intent.getBooleanExtra(RESUME_PLAYBACK, false)branch is reachedloadStreamStatenewQueue.setRecovery(newQueue.getIndex(), state.getProgressMillis());sets the recovery position to the value from DBinitPlayback(newQueue, playWhenReady);initPlaybackthen callsUIs.call(PlayerUi::initPlayback);, which in turn callsinitPlaybackon one ofBackgroundPlayerUi,PopupPlayerUi,MainPlayerUiinitPlaybackoverride in these classes callsPlayer.useVideoAndSubtitlesuseVideoAndSubtitlesdoessetRecovery()setRecovery()however gets the recovery position fromsimpleExoPlayer.getCurrentPosition()(which is effectively zero since we just started to resume playback), and this overwrites the previous recovery position we just setsetRecoveryinhandleIntentonPlaybackSynchronizegets called at some point and seeks to the recovery position (which we just set to 0)The if conditions I added are supposed to ensure
setRecoveryis only called when there is no pending recovery (it won't be overwriting a recovery position that's already been set), or when exoplayer is far along in it's setup so that there's stuff to play (timeline is not empty).I considered doing a proper refactor of this, because I don't really think calling
useVideoAndSubtitlesfrom the UIs is the best way to achieve the goal of minimizing bandwidth when playing in the background as it breaks separation of concerns, but I decided it's not worth it and can be tackled in NewPlayer at a later date.Before/After Screenshots/Screen Record
Maybe later
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.
Due diligence