diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 41eb06e8e3..007a39e485 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -357,8 +357,7 @@ public void onHostPause() { @Override public void onHostDestroy() { - stopPlayback(); - themedReactContext.removeLifecycleEventListener(this); + cleanUpResources(); } public void cleanUpResources() { @@ -998,26 +997,13 @@ private void setPlayWhenReady(boolean playWhenReady) { } } - private void startPlayback() { + private void resumePlayback() { if (player != null) { - switch (player.getPlaybackState()) { - case Player.STATE_IDLE: - case Player.STATE_ENDED: - initializePlayer(); - break; - case Player.STATE_BUFFERING: - case Player.STATE_READY: - if (!player.getPlayWhenReady()) { - setPlayWhenReady(true); - } - break; - default: - break; + if (!player.getPlayWhenReady()) { + setPlayWhenReady(true); } - } else { - initializePlayer(); + setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback); } - setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback); } private void pausePlayback() { @@ -1850,7 +1836,7 @@ public void setPausedModifier(boolean paused) { isPaused = paused; if (player != null) { if (!paused) { - startPlayback(); + resumePlayback(); } else { pausePlayback(); }