From 47326c2b4be2f25bc130f08e4800fcf998479db9 Mon Sep 17 00:00:00 2001 From: Evan farina Date: Wed, 3 Mar 2021 10:22:59 -0500 Subject: [PATCH] Removed a test and added a new test to ensure that multiple play events don't speed up the playback monitor check --- src/playback-watcher.js | 1 + test/playback-watcher.test.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/playback-watcher.js b/src/playback-watcher.js index 96413ead0..6cb84c846 100644 --- a/src/playback-watcher.js +++ b/src/playback-watcher.js @@ -133,6 +133,7 @@ export default class PlaybackWatcher { this.tech_.off('waiting', waitingHandler); this.tech_.off(timerCancelEvents, cancelTimerHandler); this.tech_.off('canplay', canPlayHandler); + this.tech_.off('play', playHandler); loaderTypes.forEach((type) => { mpc[`${type}SegmentLoader_`].off('appendsdone', loaderChecks[type].updateend); diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index ac5fdff06..7e612f1e1 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -42,12 +42,10 @@ QUnit.module('PlaybackWatcher', { } }); -QUnit.test('skips over gap at beginning of stream if player is paused', function(assert) { +QUnit.test('skips over gap at beginning of stream if played before content is buffered', function(assert) { let vhsGapSkipEvents = 0; let hlsGapSkipEvents = 0; - this.player.autoplay(true); - this.player.tech_.on('usage', (event) => { if (event.name === 'vhs-gap-skip') { vhsGapSkipEvents++; @@ -87,13 +85,10 @@ QUnit.test('skips over gap at beginning of stream if player is paused', function ); }); -QUnit.test('Does NOT skip over gap at beginning of stream if player is playing', function(assert) { +QUnit.test('Multiple play events do not cause the gap-skipping logic to be called sooner than expected', function(assert) { let vhsGapSkipEvents = 0; let hlsGapSkipEvents = 0; - this.player.autoplay(true); - this.player.tech_.paused = () => false; - this.player.tech_.on('usage', (event) => { if (event.name === 'vhs-gap-skip') { vhsGapSkipEvents++; @@ -119,17 +114,22 @@ QUnit.test('Does NOT skip over gap at beginning of stream if player is playing', // create a buffer with a gap of 2 seconds at beginning of stream this.player.tech_.buffered = () => videojs.createTimeRanges([[2, 10]]); // Playback watcher loop runs on a 250ms clock and needs run 6 consecutive stall checks before skipping the gap - this.clock.tick(250 * 6); + // Start with three consecutive playback checks + this.clock.tick(250 * 3); + // and then simulate the playback monitor being called 'manually' by a new play event + this.player.tech_.trigger('play'); + // Simulate remaining time + this.clock.tick(250 * 2); // Need to wait for the duration of the gap this.clock.tick(2000); assert.equal(vhsGapSkipEvents, 0, 'there is no skipped gap'); assert.equal(hlsGapSkipEvents, 0, 'there is no skipped gap'); - // check that player jumped the gap + // check that player did not skip the gap assert.equal( Math.round(this.player.currentTime()), - 0, 'Player did not seek over gap' + 0, 'Player seeked over gap after timer' ); });