Skip to content

Commit

Permalink
fix(skip-forward): error when clicking after player reset (#8258)
Browse files Browse the repository at this point in the history
  • Loading branch information
amtins authored May 31, 2023
1 parent e73e05d commit 07effdf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/js/control-bar/skip-buttons/skip-forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 18 additions & 0 deletions test/unit/control-bar/skip-buttons/skip-forward-button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit 07effdf

Please sign in to comment.