Skip to content

Commit

Permalink
Clear progress messages on STATE_IDLE and STATE_BUFFERING (#1768)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
benoitdion authored Sep 30, 2019
1 parent b675e59 commit b97663e
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -625,18 +625,20 @@ public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
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";
eventEmitter.ready();
onBuffering(false);
startProgressHandler();
videoLoaded();
//Setting the visibility for the playerControlView
// Setting the visibility for the playerControlView
if (playerControlView != null) {
playerControlView.show();
}
Expand All @@ -657,6 +659,15 @@ private void startProgressHandler() {
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;
Expand Down

0 comments on commit b97663e

Please sign in to comment.