mirror of
https://github.com/videojs/video.js.git
synced 2025-01-02 06:32:07 +02:00
fix(skip-forward): error when clicking after player reset (#8258)
This commit is contained in:
parent
e73e05db8f
commit
07effdf244
@ -46,6 +46,10 @@ class SkipForward extends Button {
|
||||
* to be called
|
||||
*/
|
||||
handleClick(event) {
|
||||
if (isNaN(this.player_.duration())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentVideoTime = this.player_.currentTime();
|
||||
const liveTracker = this.player_.liveTracker;
|
||||
const duration = (liveTracker && liveTracker.isLive()) ? liveTracker.seekableEnd() : this.player_.duration();
|
||||
|
@ -128,3 +128,21 @@ QUnit.test('localizes on languagechange', function(assert) {
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
QUnit.test('skips forward only if the duration is valid', function(assert) {
|
||||
const player = TestHelpers.makePlayer({controlBar: {skipButtons: {forward: 5}}});
|
||||
const currentTimeSpy = sinon.spy(player, 'currentTime');
|
||||
const button = player.controlBar.skipForward;
|
||||
|
||||
button.trigger('click');
|
||||
|
||||
assert.ok(currentTimeSpy.notCalled, 'currentTime was not called');
|
||||
|
||||
player.duration(0);
|
||||
button.trigger('click');
|
||||
|
||||
assert.ok(currentTimeSpy.called, 'currentTime was called');
|
||||
|
||||
currentTimeSpy.restore();
|
||||
player.dispose();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user