Skip to content

Commit

Permalink
fix(seeking): don't always pause in mouse down (#3886)
Browse files Browse the repository at this point in the history
In chrome 55, something changed which introduced a bug in videojs where
if you seeked back, it wouldn't work. This is because we always paused
the video in the mousedown handler.

Instead, we should create a timer for pausing that is cleared in the
mouseup handler or in the mouse move handler. This is so that if someone
is seeking by clicking and waiting the video pauses. As soon as we start
moving and we get a mousemove event, we can know that it's safe to pause
as well.

Fixes #3839.
  • Loading branch information
gkatsev committed Dec 22, 2016
1 parent 22cf3dd commit e92db4f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/js/control-bar/progress-control/seek-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ class SeekBar extends Slider {
this.player_.scrubbing(true);

this.videoWasPlaying = !this.player_.paused();
this.player_.pause();

this.pauseTimer_ = this.setTimeout(function() {
this.player_.pause();
}, 100);
}

/**
Expand All @@ -148,6 +151,11 @@ class SeekBar extends Slider {

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

if (event.type === 'mousemove') {
this.clearTimeout(this.pauseTimer_);
this.player_.pause();
}
}

/**
Expand All @@ -161,6 +169,8 @@ class SeekBar extends Slider {
handleMouseUp(event) {
super.handleMouseUp(event);

this.clearTimeout(this.pauseTimer_);

this.player_.scrubbing(false);
if (this.videoWasPlaying) {
this.player_.play();
Expand Down

0 comments on commit e92db4f

Please sign in to comment.