Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(skip-forward): error when clicking after player reset #8258

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});