mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-09-06 16:13:24 +00:00
Merge pull request #2502 from Stypox/fix-player-resume
Fix player resume
This commit is contained in:
commit
f98e5cc22d
|
@ -187,6 +187,7 @@ public abstract class BasePlayer implements
|
|||
protected MediaSessionManager mediaSessionManager;
|
||||
|
||||
private boolean isPrepared = false;
|
||||
private Disposable stateLoader;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
@ -283,16 +284,14 @@ public abstract class BasePlayer implements
|
|||
) {
|
||||
simpleExoPlayer.seekTo(playQueue.getIndex(), queue.getItem().getRecoveryPosition());
|
||||
return;
|
||||
|
||||
} else if (intent.getBooleanExtra(RESUME_PLAYBACK, false) && isPlaybackResumeEnabled()) {
|
||||
final PlayQueueItem item = queue.getItem();
|
||||
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET && isPlaybackResumeEnabled()) {
|
||||
final Disposable stateLoader = recordManager.loadStreamState(item)
|
||||
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET) {
|
||||
stateLoader = recordManager.loadStreamState(item)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doFinally(() -> {
|
||||
if (simpleExoPlayer == null) return; // doFinally called while closing
|
||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
||||
/*playOnInit=*/true);
|
||||
})
|
||||
.doFinally(() -> initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
||||
/*playOnInit=*/true))
|
||||
.subscribe(
|
||||
state -> queue.setRecovery(queue.getIndex(), state.getProgressTime()),
|
||||
error -> {
|
||||
|
@ -334,13 +333,13 @@ public abstract class BasePlayer implements
|
|||
simpleExoPlayer.removeListener(this);
|
||||
simpleExoPlayer.stop();
|
||||
simpleExoPlayer.release();
|
||||
simpleExoPlayer = null;
|
||||
}
|
||||
if (isProgressLoopRunning()) stopProgressLoop();
|
||||
if (playQueue != null) playQueue.dispose();
|
||||
if (audioReactor != null) audioReactor.dispose();
|
||||
if (playbackManager != null) playbackManager.dispose();
|
||||
if (mediaSessionManager != null) mediaSessionManager.dispose();
|
||||
if (stateLoader != null) stateLoader.dispose();
|
||||
|
||||
if (playQueueAdapter != null) {
|
||||
playQueueAdapter.unsetSelectedListener();
|
||||
|
|
Loading…
Reference in a new issue