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,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();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user