1
0
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:
André 2023-05-31 16:30:49 +02:00 committed by GitHub
parent e73e05db8f
commit 07effdf244
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -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();

View File

@ -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();
});