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:
parent
75d370742b
commit
dd3a400689
@ -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,26 +997,13 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startPlayback() {
|
private void resumePlayback() {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
switch (player.getPlaybackState()) {
|
if (!player.getPlayWhenReady()) {
|
||||||
case Player.STATE_IDLE:
|
setPlayWhenReady(true);
|
||||||
case Player.STATE_ENDED:
|
|
||||||
initializePlayer();
|
|
||||||
break;
|
|
||||||
case Player.STATE_BUFFERING:
|
|
||||||
case Player.STATE_READY:
|
|
||||||
if (!player.getPlayWhenReady()) {
|
|
||||||
setPlayWhenReady(true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback);
|
||||||
initializePlayer();
|
|
||||||
}
|
}
|
||||||
setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pausePlayback() {
|
private void pausePlayback() {
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user