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