1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 19:12:45 +01:00

Fix crash when closing a not-yet-loaded popup.

This commit is contained in:
Stypox 2019-07-25 12:32:56 +02:00
parent d076fe72cd
commit 7c9ef58acd
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23

View File

@ -288,8 +288,11 @@ public abstract class BasePlayer implements
if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET && isPlaybackResumeEnabled()) {
final Disposable stateLoader = recordManager.loadStreamState(item)
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
/*playOnInit=*/true))
.doFinally(() -> {
if (simpleExoPlayer == null) return; // doFinally called while closing
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
/*playOnInit=*/true);
})
.subscribe(
state -> queue.setRecovery(queue.getIndex(), state.getProgressTime()),
error -> {
@ -331,6 +334,7 @@ public abstract class BasePlayer implements
simpleExoPlayer.removeListener(this);
simpleExoPlayer.stop();
simpleExoPlayer.release();
simpleExoPlayer = null;
}
if (isProgressLoopRunning()) stopProgressLoop();
if (playQueue != null) playQueue.dispose();