Skip to content

Commit

Permalink
fix: update the progress-bar correctly when pausing the video and cli…
Browse files Browse the repository at this point in the history
…ck the seek-bar.

First,when handle mosue down event of the seek-bar, we set player's scrubbing_ to true, and at the same tick, the update function called and we call super.update(). however, it returns undefined because the progress equals to the previous progress, the root cause is that we get cached currentTime. So we call super.update() in the next tick to make sure we can get the correct progress.Second, when toggle visibility of the document,we should not call this.enableInterval_() when the player is paused or waiting.
Fixed videojs#6232
  • Loading branch information
ustbhuangyi committed Sep 17, 2019
1 parent de2daea commit c45b107
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/js/control-bar/progress-control/seek-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class SeekBar extends Slider {
if (document.hidden) {
this.disableInterval_(e);
} else {
this.enableInterval_();
if (!this.player_.paused() && !this.player_.hasClass('vjs-waiting')) {
this.enableInterval_();
}

// we just switched back to the page and someone may be looking, so, update ASAP
this.update();
Expand Down Expand Up @@ -133,9 +135,8 @@ class SeekBar extends Slider {
* The current percent at a number from 0-1
*/
update(event) {
const percent = super.update();

this.requestAnimationFrame(() => {
const percent = super.update();
const currentTime = this.player_.ended() ?
this.player_.duration() : this.getCurrentTime_();
const liveTracker = this.player_.liveTracker;
Expand Down Expand Up @@ -167,8 +168,6 @@ class SeekBar extends Slider {
this.duration_ = duration;
}
});

return percent;
}

/**
Expand Down

0 comments on commit c45b107

Please sign in to comment.