fix: update the progress-bar correctly when pausing the video and cli…#6234
fix: update the progress-bar correctly when pausing the video and cli…#6234ustbhuangyi wants to merge 1 commit intovideojs:masterfrom
Conversation
…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
|
💖 Thanks for opening this pull request! 💖 Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
gkatsev
left a comment
There was a problem hiding this comment.
So, the way that the progress bar is updated is either with the mousemove event or with a timeupdate event. mousedown does call our mousemove handler, and that's potentially what you're seeing with the value not being set properly. However, we also trigger a timeupdate when we finish the seek on mouseup, which the seekbar should be listening to to update itself. I'd at least expect the timeupdate handler to update things properly.
I guess it broke as part of #5879.
| } | ||
| }); | ||
|
|
||
| return percent; |
There was a problem hiding this comment.
we should still be returning this value as it may be a breaking change.
There was a problem hiding this comment.
Because the update function is throttled, so even you trigger a timeupdate event manually when finish the seek on mouseup, the update function only called once at the same tick.
There was a problem hiding this comment.
The return value of update function seems not used.
There was a problem hiding this comment.
Ah, yeah, the throttling is a good point.
While we may not be using it, if someone who uses Video.js is extending the SeekBar themselve and expecting update to return a value, they will break. We should avoid changes that have a potential breaking change in them.
There was a problem hiding this comment.
Since the percent depends on the Slider's update function. The return of undefined does not make sense.
https://github.com/videojs/video.js/blob/master/src/js/slider/slider.js#L238-L248
There was a problem hiding this comment.
I tried to remove the throttling of the update function, it works, but may cause a little perf issue. So there's a trade-off.
There was a problem hiding this comment.
@gkatsev, If you think removing the throttling of the update function is more reasonable, I will send another pr.
There was a problem hiding this comment.
No, I don't think we should unthrottle it. I'll have to think about it a bit.
There was a problem hiding this comment.
Ok, hope for a better solution.
| this.disableInterval_(e); | ||
| } else { | ||
| this.enableInterval_(); | ||
| if (!this.player_.paused() && !this.player_.hasClass('vjs-waiting')) { |
There was a problem hiding this comment.
I'm not sure that we should end up paused with vjs-waiting.
There was a problem hiding this comment.
Also, seems like this is unrelated to the actual issue, just a nice improvement?
There was a problem hiding this comment.
Yes, it's a improvement.It's no need to call update if the player is paused or waiting.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
…is set Updating cache_.currentTime as soon as the currentTime is set avoids having to wait for the timeupdate event, which results in: - making cache_.currentTime more reliable - updating the progress bar on mouse up after dragging when the media is paused. See also: videojs#6232, videojs#6234, videojs#6370, videojs#6372
…is set (#8285) Updating cache_.currentTime as soon as the currentTime is set avoids having to wait for the timeupdate event, which results in: - making cache_.currentTime more reliable - updating the progress bar on mouse up after dragging when the media is paused. See also: #6232, #6234, #6370, #6372
…is set Updating cache_.currentTime as soon as the currentTime is set avoids having to wait for the timeupdate event, which results in: - making cache_.currentTime more reliable - updating the progress bar on mouse up after dragging when the media is paused. See also: videojs#6232, videojs#6234, videojs#6370, videojs#6372
…is set (videojs#8285) Updating cache_.currentTime as soon as the currentTime is set avoids having to wait for the timeupdate event, which results in: - making cache_.currentTime more reliable - updating the progress bar on mouse up after dragging when the media is paused. See also: videojs#6232, videojs#6234, videojs#6370, videojs#6372
…is set Updating cache_.currentTime as soon as the currentTime is set avoids having to wait for the timeupdate event, which results in: - making cache_.currentTime more reliable - updating the progress bar on mouse up after dragging when the media is paused. See also: videojs#6232, videojs#6234, videojs#6370, videojs#6372
* refactor(player): decrease the indentation level in the currentTime method * fix(player): cache_.currentTime is not updated when the current time is set Updating cache_.currentTime as soon as the currentTime is set avoids having to wait for the timeupdate event, which results in: - making cache_.currentTime more reliable - updating the progress bar on mouse up after dragging when the media is paused. See also: #6232, #6234, #6370, #6372 * feat: add an option to handle smooth seeking Adds a player option called enableSmoothSeeking, which is false by default, to provide a smoother seeking experience on mobile and desktop devices. Usage: ```javascript // Enables the smooth seeking const player = videojs('player', {enableSmoothSeeking: true}); // Disable the smooth seeking player.options({enableSmoothSeeking: false}); ``` - **player.js** add an `option` called `enableSmoothSeeking` - **time-display.js** add a listener to the `seeking` event if `enableSmoothSeeking` is `true` allowing to update the `CurrentTimeDisplay` and `RemainingTimeDisplay` in real time - **seek-bar.js** `update` the seek bar on `mousemove` event if `enableSmoothSeeking` is `true` - add test cases
Description
First, when handle
mouse downevent of theseek-bar, we set player'sscrubbing_to true, and at the same tick, theupdatefunction called and we callsuper.update(). However, it returnsundefinedbecause the progress equals to the previous progress, the root cause is that we get cachedcurrentTime. So we callsuper.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 #6232
Requirements Checklist