Fix player resume
This commit is contained in:
parent
a64f520644
commit
5191907af0
|
@ -187,6 +187,7 @@ public abstract class BasePlayer implements
|
||||||
protected MediaSessionManager mediaSessionManager;
|
protected MediaSessionManager mediaSessionManager;
|
||||||
|
|
||||||
private boolean isPrepared = false;
|
private boolean isPrepared = false;
|
||||||
|
private Disposable stateLoader;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@ -283,16 +284,14 @@ public abstract class BasePlayer implements
|
||||||
) {
|
) {
|
||||||
simpleExoPlayer.seekTo(playQueue.getIndex(), queue.getItem().getRecoveryPosition());
|
simpleExoPlayer.seekTo(playQueue.getIndex(), queue.getItem().getRecoveryPosition());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (intent.getBooleanExtra(RESUME_PLAYBACK, false) && isPlaybackResumeEnabled()) {
|
} else if (intent.getBooleanExtra(RESUME_PLAYBACK, false) && isPlaybackResumeEnabled()) {
|
||||||
final PlayQueueItem item = queue.getItem();
|
final PlayQueueItem item = queue.getItem();
|
||||||
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET && isPlaybackResumeEnabled()) {
|
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET) {
|
||||||
final Disposable stateLoader = recordManager.loadStreamState(item)
|
stateLoader = recordManager.loadStreamState(item)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doFinally(() -> {
|
.doFinally(() -> initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
||||||
if (simpleExoPlayer == null) return; // doFinally called while closing
|
/*playOnInit=*/true))
|
||||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
|
||||||
/*playOnInit=*/true);
|
|
||||||
})
|
|
||||||
.subscribe(
|
.subscribe(
|
||||||
state -> queue.setRecovery(queue.getIndex(), state.getProgressTime()),
|
state -> queue.setRecovery(queue.getIndex(), state.getProgressTime()),
|
||||||
error -> {
|
error -> {
|
||||||
|
@ -334,13 +333,13 @@ public abstract class BasePlayer implements
|
||||||
simpleExoPlayer.removeListener(this);
|
simpleExoPlayer.removeListener(this);
|
||||||
simpleExoPlayer.stop();
|
simpleExoPlayer.stop();
|
||||||
simpleExoPlayer.release();
|
simpleExoPlayer.release();
|
||||||
simpleExoPlayer = null;
|
|
||||||
}
|
}
|
||||||
if (isProgressLoopRunning()) stopProgressLoop();
|
if (isProgressLoopRunning()) stopProgressLoop();
|
||||||
if (playQueue != null) playQueue.dispose();
|
if (playQueue != null) playQueue.dispose();
|
||||||
if (audioReactor != null) audioReactor.dispose();
|
if (audioReactor != null) audioReactor.dispose();
|
||||||
if (playbackManager != null) playbackManager.dispose();
|
if (playbackManager != null) playbackManager.dispose();
|
||||||
if (mediaSessionManager != null) mediaSessionManager.dispose();
|
if (mediaSessionManager != null) mediaSessionManager.dispose();
|
||||||
|
if (stateLoader != null) stateLoader.dispose();
|
||||||
|
|
||||||
if (playQueueAdapter != null) {
|
if (playQueueAdapter != null) {
|
||||||
playQueueAdapter.unsetSelectedListener();
|
playQueueAdapter.unsetSelectedListener();
|
||||||
|
|
Loading…
Reference in New Issue