Skip to content

Commit

Permalink
feat: add an option to handle smooth seeking
Browse files Browse the repository at this point in the history
  • Loading branch information
amtins committed May 19, 2023
1 parent f1558c6 commit 8292be6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/js/control-bar/progress-control/seek-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class SeekBar extends Slider {
* @private
*/
getCurrentTime_() {
return (this.player_.scrubbing()) ?
return (this.player_.scrubbing()) || !this.options_.playerOptions.enableSmoothSeeking ?
this.player_.getCache().currentTime :
this.player_.currentTime();
}
Expand Down Expand Up @@ -324,6 +324,10 @@ class SeekBar extends Slider {

// Set new time (tell player to seek to new time)
this.userSeek_(newTime);

if (this.options_.playerOptions.enableSmoothSeeking) {
this.update();
}
}

enable() {
Expand Down
8 changes: 7 additions & 1 deletion src/js/control-bar/time-controls/time-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ class TimeDisplay extends Component {
constructor(player, options) {
super(player, options);

this.on(player, ['timeupdate', 'ended'], (e) => this.updateContent(e));
const types = ['timeupdate', 'ended'];

if (options.playerOptions.enableSmoothSeeking) {
types.push('seeking');
}

this.on(player, types, (e) => this.updateContent(e));
this.updateTextNode_();
}

Expand Down

0 comments on commit 8292be6

Please sign in to comment.