8000 fix(seek-bar): error when scrubbing after player reset (#8257) · videojs/video.js@e73e05d · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit e73e05d

Browse files
authored
fix(seek-bar): error when scrubbing after player reset (#8257)
1 parent 5151bc5 commit e73e05d

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/js/control-bar/progress-control/seek-bar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class SeekBar extends Slider {
273273
* @listens mousemove
274274
*/
275275
handleMouseMove(event, mouseDown = false) {
276-
if (!Dom.isSingleLeftClick(event)) {
276+
if (!Dom.isSingleLeftClick(event) || isNaN(this.player_.duration())) {
277277
return;
278278
}
279279

test/unit/controls.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ QUnit.test("SeekBar doesn't set scrubbing on mouse down, only on mouse move", fu
151151
const seekBar = new SeekBar(player);
152152
const doc = new EventTarget();
153153

154+
player.duration(0);
155+
154156
// mousemove is listened to on the document.
155157
// Specifically, we check the ownerDocument of the seekBar's bar.
156158
// Therefore, we want to mock it out to be able to trigger mousemove

test/unit/reset-ui.test.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,29 @@ QUnit.test('Calling resetProgressBar should reset the components displaying time
5252

5353
// Do reset
5454
player.resetProgressBar_();
55-
player.duration(0);
55+
// Allows to have a duration state similar to player.reset() by combining the durationchange
56+
player.duration(NaN);
57+
player.trigger('durationchange');
5658
clock.tick(30);
5759

60+
const calculateDistance = sinon.spy(seekBar, 'calculateDistance');
61+
62+
// Simulate a mouse move
63+
seekBar.handleMouseMove({ offsetX: 1 });
64+
5865
assert.equal(player.currentTime(), 0, 'player current time is 0');
5966

6067
// Current time display
6168
assert.equal(currentTimeDisplay.textNode_.textContent, '0:00', 'current time display is 0:00');
6269
// Duration display
63-
assert.equal(durationDisplay.textNode_.textContent, '0:00', 'duration display is 0:00');
70+
assert.equal(durationDisplay.textNode_.textContent, '-:-', 'duration display is -:-');
6471
// Remaining time display
65-
assert.equal(remainingTimeDisplay.textNode_.textContent, '0:00', 'remaining time display is 0:00');
72+
assert.equal(remainingTimeDisplay.textNode_.textContent, '-:-', 'remaining time display is -:-');
6673
// Seek bar
6774
assert.equal(seekBar.getProgress(), '0', 'seek bar progress is 0');
68-
assert.equal(seekBar.getAttribute('aria-valuetext'), '0:00 of 0:00', 'seek bar progress holder aria value text is 0:00 of 0:00');
75+
assert.equal(seekBar.getAttribute('aria-valuetext'), '0:00 of -:-', 'seek bar progress holder aria value text is 0:00 of -:-');
6976
assert.equal(seekBar.getAttribute('aria-valuenow'), '0.00', 'seek bar progress holder aria value now is 0.00');
77+
assert.ok(!calculateDistance.called, 'calculateDistance was not called');
7078
// Load progress
7179
assert.equal(seekBar.loadProgressBar.el().textContent, 'Loaded: 0.00%', 'load progress bar textContent is Loaded: 0.00%');
7280
assert.equal(seekBar.loadProgressBar.el().style.width, '0%', 'load progress bar width is 0%');
@@ -76,6 +84,7 @@ QUnit.test('Calling resetProgressBar should reset the components displaying time
7684
assert.equal(seekBar.playProgressBar.timeTooltip.el().textContent, '0:00', 'player progress bar time tooltip is 0:00');
7785

7886
clock.restore();
87+
calculateDistance.restore();
7988
player.dispose();
8089
});
8190

0 commit comments

Comments
 (0)
0