Clear progress messages on STATE_IDLE and STATE_BUFFERING (#1768)

The progress message handler will duplicate recursions of the `onProgressMessage` handler on change of player state from any state to STATE_READY with `playWhenReady` is true (when video is not paused). This clears the messages on STATE_IDLE and STATE_BUFFERING to break the recursion.
This commit is contained in:
Benoit Dion 2019-09-30 13:27:08 -04:00 committed by GitHub
parent b675e59162
commit b97663e092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -625,10 +625,12 @@ class ReactExoplayerView extends FrameLayout implements
case Player.STATE_IDLE:
text += "idle";
eventEmitter.idle();
clearProgressMessageHandler();
break;
case Player.STATE_BUFFERING:
text += "buffering";
onBuffering(true);
clearProgressMessageHandler();
break;
case Player.STATE_READY:
text += "ready";
@ -636,7 +638,7 @@ class ReactExoplayerView extends FrameLayout implements
onBuffering(false);
startProgressHandler();
videoLoaded();
//Setting the visibility for the playerControlView
// Setting the visibility for the playerControlView
if (playerControlView != null) {
playerControlView.show();
}
@ -657,6 +659,15 @@ class ReactExoplayerView extends FrameLayout implements
progressHandler.sendEmptyMessage(SHOW_PROGRESS);
}
/*
The progress message handler will duplicate recursions of the onProgressMessage handler
on change of player state from any state to STATE_READY with playWhenReady is true (when
the video is not paused). This clears all existing messages.
*/
private void clearProgressMessageHandler() {
progressHandler.removeMessages(SHOW_PROGRESS);
}
private void videoLoaded() {
if (loadVideoStarted) {
loadVideoStarted = false;