Chore/fix strange management of resume (#3629)

* fix(android): rename startPlayback to resumePlayback and fix implementation

I cannot understand why this implementation has been done. I guess this is to workaround some issue...
now resume only resume playback and don't start a new playback during bufffering...

* chore: simplify duplicated code
This commit is contained in:
Olivier Bouillet 2024-03-29 20:59:58 +01:00 committed by GitHub
parent 75d370742b
commit dd3a400689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -357,8 +357,7 @@ public class ReactExoplayerView extends FrameLayout implements
@Override @Override
public void onHostDestroy() { public void onHostDestroy() {
stopPlayback(); cleanUpResources();
themedReactContext.removeLifecycleEventListener(this);
} }
public void cleanUpResources() { public void cleanUpResources() {
@ -998,27 +997,14 @@ public class ReactExoplayerView extends FrameLayout implements
} }
} }
private void startPlayback() { private void resumePlayback() {
if (player != null) { 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()) { if (!player.getPlayWhenReady()) {
setPlayWhenReady(true); setPlayWhenReady(true);
} }
break;
default:
break;
}
} else {
initializePlayer();
}
setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback); setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback);
} }
}
private void pausePlayback() { private void pausePlayback() {
if (player != null) { if (player != null) {
@ -1850,7 +1836,7 @@ public class ReactExoplayerView extends FrameLayout implements
isPaused = paused; isPaused = paused;
if (player != null) { if (player != null) {
if (!paused) { if (!paused) {
startPlayback(); resumePlayback();
} else { } else {
pausePlayback(); pausePlayback();
} }