Skip to content

Commit 07effdf

Browse files
authored
fix(skip-forward): error when clicking after player reset (#8258)
1 parent e73e05d commit 07effdf

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/js/control-bar/skip-buttons/skip-forward.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class SkipForward extends Button {
4646
* to be called
4747
*/
4848
handleClick(event) {
49+
if (isNaN(this.player_.duration())) {
50+
return;
51+
}
52+
4953
const currentVideoTime = this.player_.currentTime();
5054
const liveTracker = this.player_.liveTracker;
5155
const duration = (liveTracker && liveTracker.isLive()) ? liveTracker.seekableEnd() : this.player_.duration();

test/unit/control-bar/skip-buttons/skip-forward-button.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,21 @@ QUnit.test('localizes on languagechange', function(assert) {
128128

129129
player.dispose();
130130
});
131+
132+
QUnit.test('skips forward only if the duration is valid', function(assert) {
133+
const player = TestHelpers.makePlayer({controlBar: {skipButtons: {forward: 5}}});
134+
const currentTimeSpy = sinon.spy(player, 'currentTime');
135+
const button = player.controlBar.skipForward;
136+
137+
button.trigger('click');
138+
139+
assert.ok(currentTimeSpy.notCalled, 'currentTime was not called');
140+
141+
player.duration(0);
142+
button.trigger('click');
143+
144+
assert.ok(currentTimeSpy.called, 'currentTime was called');
145+
146+
currentTimeSpy.restore();
147+
player.dispose();
148+
});

0 commit comments

Comments
 (0)