Skip to content

Commit

Permalink
Chore/fix strange management of resume (#3629)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
freeboub authored Mar 29, 2024
1 parent 75d3707 commit dd3a400
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ public void onHostPause() {

@Override
public void onHostDestroy() {
stopPlayback();
themedReactContext.removeLifecycleEventListener(this);
cleanUpResources();
}

public void cleanUpResources() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -1850,7 +1836,7 @@ public void setPausedModifier(boolean paused) {
isPaused = paused;
if (player != null) {
if (!paused) {
startPlayback();
resumePlayback();
} else {
pausePlayback();
}
Expand Down

0 comments on commit dd3a400

Please sign in to comment.