diff --git a/demo/common/message_ids.js b/demo/common/message_ids.js index 6ddc23d326..76b4eab01c 100644 --- a/demo/common/message_ids.js +++ b/demo/common/message_ids.js @@ -195,7 +195,6 @@ shakaDemo.MessageIds = { IGNORE_TEXT_FAILURES: 'DEMO_IGNORE_TEXT_FAILURES', INACCURATE_MANIFEST_TOLERANCE: 'DEMO_INACCURATE_MANIFEST_TOLERANCE', INITIAL_SEGMENT_LIMIT: 'DEMO_INITIAL_SEGMENT_LIMIT', - JUMP_LARGE_GAPS: 'DEMO_JUMP_LARGE_GAPS', LANGUAGE_SECTION_HEADER: 'DEMO_LANGUAGE_SECTION_HEADER', LOG_LEVEL: 'DEMO_LOG_LEVEL', LOG_LEVEL_DEBUG: 'DEMO_LOG_LEVEL_DEBUG', @@ -211,7 +210,6 @@ shakaDemo.MessageIds = { MAX_FRAMERATE: 'DEMO_MAX_FRAMERATE', MAX_HEIGHT: 'DEMO_MAX_HEIGHT', MAX_PIXELS: 'DEMO_MAX_PIXELS', - MAX_SMALL_GAP_SIZE: 'DEMO_MAX_SMALL_GAP_SIZE', MAX_WIDTH: 'DEMO_MAX_WIDTH', MIN_BANDWIDTH: 'DEMO_MIN_BANDWIDTH', MIN_BYTES: 'DEMO_MIN_BYTES', diff --git a/demo/config.js b/demo/config.js index ae8fc448ee..b44071df05 100644 --- a/demo/config.js +++ b/demo/config.js @@ -352,9 +352,6 @@ shakaDemo.Config = class { .addNumberInput_(MessageIds.GAP_DETECTION_THRESHOLD, 'streaming.gapDetectionThreshold', /* canBeDecimal= */ true) - .addNumberInput_(MessageIds.MAX_SMALL_GAP_SIZE, - 'streaming.smallGapLimit', - /* canBeDecimal= */ true) .addNumberInput_(MessageIds.BUFFERING_GOAL, 'streaming.bufferingGoal', /* canBeDecimal= */ true) @@ -407,10 +404,8 @@ shakaDemo.Config = class { this.latestInput_.input().checked = true; } - this.addBoolInput_(MessageIds.JUMP_LARGE_GAPS, - 'streaming.jumpLargeGaps') - .addBoolInput_(MessageIds.FORCE_TRANSMUX_TS, - 'streaming.forceTransmuxTS') + this.addBoolInput_(MessageIds.FORCE_TRANSMUX_TS, + 'streaming.forceTransmuxTS') .addBoolInput_(MessageIds.START_AT_SEGMENT_BOUNDARY, 'streaming.startAtSegmentBoundary') .addBoolInput_(MessageIds.IGNORE_TEXT_FAILURES, diff --git a/demo/demo_utils.js b/demo/demo_utils.js index 4489ac7214..6f4825d74b 100644 --- a/demo/demo_utils.js +++ b/demo/demo_utils.js @@ -43,7 +43,6 @@ shakaDemo.Utils = class { // Override config values that are handled manually. overridden.push('abr.enabled'); - overridden.push('streaming.jumpLargeGaps'); overridden.push('drm.advanced'); overridden.push('drm.servers'); diff --git a/demo/locales/en.json b/demo/locales/en.json index d51d7a676e..080c9457ac 100644 --- a/demo/locales/en.json +++ b/demo/locales/en.json @@ -108,7 +108,6 @@ "DEMO_INVALID_JSON_CONFIG_ERROR": "Invalid JSON configuration", "DEMO_IRT": "IRT", "DEMO_JSDELIVR": "jsDelivr", - "DEMO_JUMP_LARGE_GAPS": "Jump Large Gaps", "DEMO_LANGUAGE_SECTION_HEADER": "Language", "DEMO_LIBRARIES": "Google Hosted Libraries", "DEMO_LICENSE": "Apache License", @@ -137,7 +136,6 @@ "DEMO_MAX_FRAMERATE": "Max Framerate", "DEMO_MAX_HEIGHT": "Max Height", "DEMO_MAX_PIXELS": "Max Pixels", - "DEMO_MAX_SMALL_GAP_SIZE": "Maximum Small Gap Size", "DEMO_MAX_WIDTH": "Max Width", "DEMO_METACDN": "MetaCDN", "DEMO_MICROSOFT": "Microsoft", diff --git a/demo/locales/source.json b/demo/locales/source.json index d005b400bb..753888df71 100644 --- a/demo/locales/source.json +++ b/demo/locales/source.json @@ -435,10 +435,6 @@ "description": "A link in the footer, to Shaka Player in the jsDelivr CDN.", "message": "[PROPER_NAME:jsDelivr]" }, - "DEMO_JUMP_LARGE_GAPS": { - "description": "The name of a configuration value.", - "message": "Jump Large Gaps" - }, "DEMO_LANGUAGE_SECTION_HEADER": { "description": "The header for a section of configuration values.", "message": "Language" @@ -551,10 +547,6 @@ "description": "The name of a configuration value.", "message": "Max Pixels" }, - "DEMO_MAX_SMALL_GAP_SIZE": { - "description": "The name of a configuration value.", - "message": "Maximum Small Gap Size" - }, "DEMO_MAX_WIDTH": { "description": "The name of a configuration value.", "message": "Max Width" diff --git a/demo/main.js b/demo/main.js index 5e6901d3dc..c3d3b26092 100644 --- a/demo/main.js +++ b/demo/main.js @@ -944,9 +944,6 @@ shakaDemo.Main = class { if ('noadaptation' in params) { this.configure('abr.enabled', false); } - if ('jumpLargeGaps' in params) { - this.configure('streaming.jumpLargeGaps', true); - } // Add compiled/uncompiled links. this.makeVersionLinks_(); @@ -1357,9 +1354,6 @@ shakaDemo.Main = class { if (!this.getCurrentConfigValue('abr.enabled')) { params.push('noadaptation'); } - if (this.getCurrentConfigValue('streaming.jumpLargeGaps')) { - params.push('jumpLargeGaps'); - } params.push('uilang=' + this.getUILocale()); if (this.selectedAsset) { diff --git a/docs/tutorials/config.md b/docs/tutorials/config.md index 9d655e77dc..2a23ccbf65 100644 --- a/docs/tutorials/config.md +++ b/docs/tutorials/config.md @@ -73,10 +73,8 @@ player.getConfiguration(); failureCallback: Function ignoreTextStreamFailures: false alwaysStreamText: false - jumpLargeGaps: false rebufferingGoal: 2 retryParameters: Object - smallGapLimit: 0.5 startAtSegmentBoundary: false safeSeekOffset: 5 textDisplayFactory: Function diff --git a/docs/tutorials/upgrade.md b/docs/tutorials/upgrade.md index 7e9b6bc3a6..fb20835d75 100644 --- a/docs/tutorials/upgrade.md +++ b/docs/tutorials/upgrade.md @@ -44,6 +44,8 @@ application: constructors; these will not be invoked with `new` (deprecated in v3.1.0) - `drm.initDataTransform` has been removed (no longer needed since the minimum supported version of iOS is now 13) + - `streaming.smallGapLimit` and `streaming.jumpLargeGaps` have been removed; + all gaps will now be jumped - Player API changes: - `shaka.Player.prototype.addTextTrack()` has been replaced by diff --git a/externs/shaka/player.js b/externs/shaka/player.js index c3d6d1ed3a..886fffb5f8 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -838,8 +838,6 @@ shaka.extern.ManifestConfiguration; * alwaysStreamText: boolean, * startAtSegmentBoundary: boolean, * gapDetectionThreshold: number, - * smallGapLimit: number, - * jumpLargeGaps: boolean, * durationBackoff: number, * forceTransmuxTS: boolean, * safeSeekOffset: number, @@ -894,18 +892,8 @@ shaka.extern.ManifestConfiguration; * to false. * @property {number} gapDetectionThreshold * TThe maximum distance (in seconds) before a gap when we'll automatically - * jump. This value defaults to 0.1, except in Edge Legacy, IE, + * jump. This value defaults to 0.1, except in Edge Legacy, * Tizen, Chromecast that value defaults value is 0.5 - * @property {number} smallGapLimit - * The limit (in seconds) for a gap in the media to be considered "small". - * Small gaps are jumped automatically without events. Large gaps result - * in a Player event and can be jumped. - * @property {boolean} jumpLargeGaps - * If true, jump large gaps in addition to small gaps. A - * largegap event will be raised first. Then, if the app doesn't - * call preventDefault() on the event, the Player will jump the - * gap. If false, then the event will be raised, but the gap - * will not be jumped. * @property {number} durationBackoff * By default, we will not allow seeking to exactly the duration of a * presentation. This field is the number of seconds before duration we will diff --git a/lib/media/gap_jumping_controller.js b/lib/media/gap_jumping_controller.js index da3cfd41b5..636fd245ac 100644 --- a/lib/media/gap_jumping_controller.js +++ b/lib/media/gap_jumping_controller.js @@ -11,7 +11,6 @@ goog.require('shaka.media.PresentationTimeline'); goog.require('shaka.media.StallDetector'); goog.require('shaka.media.TimeRangesUtils'); goog.require('shaka.util.EventManager'); -goog.require('shaka.util.FakeEvent'); goog.require('shaka.util.IReleasable'); goog.require('shaka.util.Timer'); @@ -33,10 +32,8 @@ shaka.media.GapJumpingController = class { * playable region. The gap jumping controller takes ownership over the * stall detector. * If no stall detection logic is desired, |null| may be provided. - * @param {function(!Event)} onEvent Called when an event is raised to be sent - * to the application. */ - constructor(video, timeline, config, stallDetector, onEvent) { + constructor(video, timeline, config, stallDetector) { /** @private {HTMLMediaElement} */ this.video_ = video; @@ -46,9 +43,6 @@ shaka.media.GapJumpingController = class { /** @private {?shaka.extern.StreamingConfiguration} */ this.config_ = config; - /** @private {?function(!Event)} */ - this.onEvent_ = onEvent; - /** @private {shaka.util.EventManager} */ this.eventManager_ = new shaka.util.EventManager(); @@ -58,9 +52,6 @@ shaka.media.GapJumpingController = class { /** @private {number} */ this.prevReadyState_ = video.readyState; - /** @private {boolean} */ - this.didFireLargeGap_ = false; - /** * The stall detector tries to keep the playhead moving forward. It is * managed by the gap-jumping controller to avoid conflicts. On some @@ -107,7 +98,6 @@ shaka.media.GapJumpingController = class { this.stallDetector_ = null; } - this.onEvent_ = null; this.timeline_ = null; this.video_ = null; } @@ -128,7 +118,6 @@ shaka.media.GapJumpingController = class { onSeeking() { this.seekingEventReceived_ = true; this.hadSegmentAppended_ = false; - this.didFireLargeGap_ = false; } @@ -165,7 +154,6 @@ shaka.media.GapJumpingController = class { // When the ready state changes, we have moved on, so we should fire the // large gap event if we see one. if (this.video_.readyState != this.prevReadyState_) { - this.didFireLargeGap_ = false; this.prevReadyState_ = this.video_.readyState; } @@ -175,7 +163,6 @@ shaka.media.GapJumpingController = class { } - const smallGapLimit = this.config_.smallGapLimit; const currentTime = this.video_.currentTime; const buffered = this.video_.buffered; const gapDetectionThreshold = this.config_.gapDetectionThreshold; @@ -203,8 +190,6 @@ shaka.media.GapJumpingController = class { } const jumpSize = jumpTo - currentTime; - const isGapSmall = jumpSize <= smallGapLimit; - let jumpLargeGap = false; // If we jump to exactly the gap start, we may detect a small gap due to // rounding errors or browser bugs. We can ignore these extremely small @@ -213,37 +198,17 @@ shaka.media.GapJumpingController = class { return; } - if (!isGapSmall && !this.didFireLargeGap_) { - this.didFireLargeGap_ = true; - - // Event firing is synchronous. - const data = new Map() - .set('currentTime', currentTime) - .set('gapSize', jumpSize); - const event = new shaka.util.FakeEvent('largegap', data); - event.cancelable = true; - this.onEvent_(event); - - if (this.config_.jumpLargeGaps && !event.defaultPrevented) { - jumpLargeGap = true; - } else { - shaka.log.info('Ignoring large gap at', currentTime, 'size', jumpSize); - } + if (gapIndex == 0) { + shaka.log.info( + 'Jumping forward', jumpSize, + 'seconds because of gap before start time of', jumpTo); + } else { + shaka.log.info( + 'Jumping forward', jumpSize, 'seconds because of gap starting at', + buffered.end(gapIndex - 1), 'and ending at', jumpTo); } - if (isGapSmall || jumpLargeGap) { - if (gapIndex == 0) { - shaka.log.info( - 'Jumping forward', jumpSize, - 'seconds because of gap before start time of', jumpTo); - } else { - shaka.log.info( - 'Jumping forward', jumpSize, 'seconds because of gap starting at', - buffered.end(gapIndex - 1), 'and ending at', jumpTo); - } - - this.video_.currentTime = jumpTo; - } + this.video_.currentTime = jumpTo; } }; diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 8fd1931161..69ea1b1b03 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -418,17 +418,15 @@ shaka.media.MediaSourceEngine = class { * * @param {shaka.util.ManifestParserUtils.ContentType} contentType * @param {number} time Playhead time - * @param {number=} smallGapLimit * @return {boolean} */ - isBuffered(contentType, time, smallGapLimit) { + isBuffered(contentType, time) { const ContentType = shaka.util.ManifestParserUtils.ContentType; if (contentType == ContentType.TEXT) { return this.textEngine_.isBuffered(time); } else { const buffered = this.getBuffered_(contentType); - return shaka.media.TimeRangesUtils.isBuffered( - buffered, time, smallGapLimit); + return shaka.media.TimeRangesUtils.isBuffered(buffered, time); } } diff --git a/lib/media/playhead.js b/lib/media/playhead.js index 9c491d9808..462af1907c 100644 --- a/lib/media/playhead.js +++ b/lib/media/playhead.js @@ -160,10 +160,8 @@ shaka.media.MediaSourcePlayhead = class { * @param {function()} onSeek * Called when the user agent seeks to a time within the presentation * timeline. - * @param {function(!Event)} onEvent - * Called when an event is raised to be sent to the application. */ - constructor(mediaElement, manifest, config, startTime, onSeek, onEvent) { + constructor(mediaElement, manifest, config, startTime, onSeek) { /** * The seek range must be at least this number of seconds long. If it is * smaller than this, change it to be this big so we don't repeatedly seek @@ -199,8 +197,7 @@ shaka.media.MediaSourcePlayhead = class { mediaElement, manifest.presentationTimeline, config, - this.createStallDetector_(mediaElement, config), - onEvent); + this.createStallDetector_(mediaElement, config)); /** @private {shaka.media.VideoWrapper} */ this.videoWrapper_ = new shaka.media.VideoWrapper( diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index 7af7728a55..3d79bdc645 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -606,11 +606,10 @@ shaka.media.StreamingEngine = class { */ seeked() { const presentationTime = this.playerInterface_.getPresentationTime(); - const smallGapLimit = this.config_.smallGapLimit; const ContentType = shaka.util.ManifestParserUtils.ContentType; const newTimeIsBuffered = (type) => { return this.playerInterface_.mediaSourceEngine.isBuffered( - type, presentationTime, smallGapLimit); + type, presentationTime); }; let streamCleared = false; diff --git a/lib/media/time_ranges_utils.js b/lib/media/time_ranges_utils.js index 7718389ed0..79e3d84351 100644 --- a/lib/media/time_ranges_utils.js +++ b/lib/media/time_ranges_utils.js @@ -54,17 +54,13 @@ shaka.media.TimeRangesUtils = class { /** - * Determines if the given time is inside a buffered range. This includes - * gaps, meaning that if the playhead is in a gap, it is considered buffered. - * If there is a small gap between the playhead and buffer start, consider it - * as buffered. + * Determines if the given time is inside a buffered range. * * @param {TimeRanges} b * @param {number} time Playhead time - * @param {number=} smallGapLimit Set in configuration * @return {boolean} */ - static isBuffered(b, time, smallGapLimit = 0) { + static isBuffered(b, time) { if (!b || !b.length) { return false; } @@ -76,9 +72,8 @@ shaka.media.TimeRangesUtils = class { if (time > b.end(b.length - 1)) { return false; } - // Push the time forward by the gap limit so that it is more likely to be in - // the range. - return (time + smallGapLimit >= b.start(0)); + + return time >= b.start(0); } diff --git a/lib/player.js b/lib/player.js index a10c3ab038..184f1b5fa7 100644 --- a/lib/player.js +++ b/lib/player.js @@ -300,22 +300,6 @@ goog.requireType('shaka.routing.Payload'); */ -/** - * @event shaka.Player.LargeGapEvent - * @description Fired when the playhead enters a large gap. If the - * streaming.jumpLargeGaps configuration is set, the default - * action of this event is to jump the gap; this can be prevented by calling - * preventDefault() on the event object. - * @property {string} type - * 'largegap' - * @property {number} currentTime - * The current time of the playhead. - * @property {number} gapSize - * The size of the gap, in seconds. - * @exportDoc - */ - - /** * @event shaka.Player.ManifestParsedEvent * @description Fired after the manifest has been parsed, but before anything @@ -2676,8 +2660,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { this.manifest_, this.config_.streaming, startTime, - () => this.onSeek_(), - (event) => this.dispatchEvent(event)); + () => this.onSeek_()); } /** @@ -6350,7 +6333,6 @@ shaka.Player.EventName = { Emsg: 'emsg', Error: 'error', ExpirationUpdated: 'expirationupdated', - LargeGap: 'largegap', Loaded: 'loaded', Loading: 'loading', ManifestParsed: 'manifestparsed', diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index f9709f4d77..6a6eda9c4a 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -149,8 +149,6 @@ shaka.util.PlayerConfiguration = class { alwaysStreamText: false, startAtSegmentBoundary: false, gapDetectionThreshold: 0.1, - smallGapLimit: 0.5, - jumpLargeGaps: false, durationBackoff: 1, forceTransmuxTS: false, // Offset by 5 seconds since Chromecast takes a few seconds to start diff --git a/test/media/playhead_unit.js b/test/media/playhead_unit.js index 0e9b149c4d..98dffc5950 100644 --- a/test/media/playhead_unit.js +++ b/test/media/playhead_unit.js @@ -21,16 +21,12 @@ let TimeRange; * start: number, * waitingAt: number, * expectedEndTime: number, - * expectEvent: boolean, - * jumpLargeGaps: (boolean|undefined), - * preventDefault: (boolean|undefined) * }} * * @description * Parameters for a test where we start playing inside a buffered range and play * until the end of the buffer. Then, if we expect it, Playhead should jump - * to the expected time. Also, if the gap is large, we should get a 'largegap' - * event from the Playhead, which we may optionally suppress. + * to the expected time. * * @property {!Array.} buffered * The buffered ranges for the test. @@ -40,12 +36,6 @@ let TimeRange; * The time to pause at and fire a 'waiting' event. * @property {number} expectedEndTime * The expected time at the end of the test. - * @property {boolean} expectEvent - * If true, expect the 'largegap' event to be fired. - * @property {(boolean|undefined)} jumpLargeGaps - * If given, set this field of the Playhead configuration. - * @property {(boolean|undefined)} preventDefault - * If true, call preventDefault() on the 'largegap' event. */ let PlayingTestInfo; @@ -57,17 +47,12 @@ let PlayingTestInfo; * start: number, * seekTo: number, * expectedEndTime: number, - * expectEvent: boolean, - * jumpLargeGaps: (boolean|undefined), - * preventDefault: (boolean|undefined) * }} * * @description * Parameters for a test where we start playing inside a buffered range and seek * to a given time, which may have different buffered ranges. If we are in a - * gap, Playhead should jump the gap to the expected time. Also, if the gap is - * large, we should get a 'largegap' event from the Playhead, which we may - * optionally suppress. + * gap, Playhead should jump the gap to the expected time. * * @property {!Array.} buffered * The buffered ranges for the test. @@ -80,12 +65,6 @@ let PlayingTestInfo; * The time to seek to. * @property {number} expectedEndTime * The expected time at the end of the test. - * @property {boolean} expectEvent - * If true, expect the 'largegap' event to be fired. - * @property {(boolean|undefined)} jumpLargeGaps - * If given, set this field of the Playhead configuration. - * @property {(boolean|undefined)} preventDefault - * If true, call preventDefault() on the 'largegap' event. */ let SeekTestInfo; @@ -108,10 +87,6 @@ describe('Playhead', () => { /** @type {!jasmine.Spy} */ let onSeek; - // Callback to us from Playhead when an event should be sent to the app. - /** @type {!jasmine.Spy} */ - let onEvent; - beforeAll(() => { jasmine.clock().install(); }); @@ -125,7 +100,6 @@ describe('Playhead', () => { timeline = new shaka.test.FakePresentationTimeline(); onSeek = jasmine.createSpy('onSeek'); - onEvent = jasmine.createSpy('onEvent'); timeline.isLive.and.returnValue(false); timeline.getSeekRangeStart.and.returnValue(5); @@ -169,8 +143,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); expect(video.currentTime).toBe(5); expect(playhead.getTime()).toBe(5); @@ -190,8 +163,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); expect(video.addEventListener).toHaveBeenCalledWith( 'loadedmetadata', jasmine.any(Function), jasmine.anything()); @@ -231,8 +203,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); video.on['seeking'](); expect(playhead.getTime()).toBe(5); @@ -250,8 +221,7 @@ describe('Playhead', () => { timeline.getSeekRangeEnd.and.returnValue(60); playhead = new shaka.media.MediaSourcePlayhead( - video, manifest, config, /* startTime= */ 0, Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + video, manifest, config, /* startTime= */ 0, Util.spyFunc(onSeek)); expect(playhead.getTime()).toBe(0); }); @@ -264,8 +234,7 @@ describe('Playhead', () => { timeline.getDuration.and.returnValue(60); playhead = new shaka.media.MediaSourcePlayhead( - video, manifest, config, /* startTime= */ 60, Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + video, manifest, config, /* startTime= */ 60, Util.spyFunc(onSeek)); expect(playhead.getTime()).toBe(59); // duration - durationBackoff expect(video.currentTime).toBe(59); // duration - durationBackoff @@ -279,8 +248,7 @@ describe('Playhead', () => { timeline.getSeekRangeEnd.and.returnValue(60); playhead = new shaka.media.MediaSourcePlayhead( - video, manifest, config, /* startTime= */ -15, Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + video, manifest, config, /* startTime= */ -15, Util.spyFunc(onSeek)); expect(playhead.getTime()).toBe(45); }); @@ -294,8 +262,7 @@ describe('Playhead', () => { // If the live stream's playback offset time is not available, start // playing from the seek range start time. playhead = new shaka.media.MediaSourcePlayhead( - video, manifest, config, /* startTime= */ -40, Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + video, manifest, config, /* startTime= */ -40, Util.spyFunc(onSeek)); expect(playhead.getTime()).toBe(30); }); @@ -306,8 +273,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); expect(video.addEventListener).toHaveBeenCalledWith( 'loadedmetadata', jasmine.any(Function), jasmine.anything()); @@ -339,8 +305,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ null, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); expect(video.addEventListener).toHaveBeenCalledWith( 'loadedmetadata', jasmine.any(Function), jasmine.anything()); @@ -372,8 +337,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); // This has to periodically increment the mock date to allow the onSeeking_ // handler to seek, if appropriate. @@ -532,8 +496,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); setMockDate(0); video.on['seeking'](); @@ -581,8 +544,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); // First, seek to start time. video.currentTime = 0; @@ -642,8 +604,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); expect(currentTime).toBe(1000); seekCount = 0; @@ -688,8 +649,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); video.on['seeking'](); expect(video.currentTime).toBe(5); @@ -720,8 +680,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); video.on['seeking'](); expect(video.currentTime).toBe(5); @@ -755,8 +714,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 30, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); video.currentTime = 0; video.seeking = true; @@ -801,8 +759,7 @@ describe('Playhead', () => { manifest, config, /* startTime= */ 30, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); /** * Prevent retries on the initial start time seek. This will ensure that @@ -833,8 +790,6 @@ describe('Playhead', () => { timeline.getSeekRangeStart.and.returnValue(0); timeline.getSeekRangeEnd.and.returnValue(60); timeline.getDuration.and.returnValue(60); - - config.smallGapLimit = 1; }); describe('when playing', () => { @@ -843,7 +798,6 @@ describe('Playhead', () => { buffered: [{start: 0, end: 10}], start: 3, waitingAt: 10, - expectEvent: false, expectedEndTime: 10, }); @@ -851,7 +805,6 @@ describe('Playhead', () => { buffered: [{start: 0, end: 10}, {start: 20, end: 30}], start: 24, waitingAt: 30, - expectEvent: false, expectedEndTime: 30, }); @@ -859,7 +812,6 @@ describe('Playhead', () => { buffered: [{start: 0, end: 10}, {start: 11, end: 20}], start: 5, waitingAt: 10, - expectEvent: false, expectedEndTime: 11, }); @@ -868,7 +820,6 @@ describe('Playhead', () => { [{start: 0, end: 10}, {start: 11, end: 20}, {start: 21, end: 30}], start: 5, waitingAt: 10, - expectEvent: false, expectedEndTime: 11, }); @@ -877,26 +828,15 @@ describe('Playhead', () => { [{start: 0, end: 10}, {start: 11, end: 20}, {start: 21, end: 30}], start: 15, waitingAt: 20, - expectEvent: false, expectedEndTime: 21, }); }); // with small gaps describe('with large gaps', () => { - playingTest('will fire an event', { - buffered: [{start: 0, end: 10}, {start: 30, end: 40}], - start: 5, - waitingAt: 10, - expectEvent: true, - expectedEndTime: 10, - }); - playingTest('will jump large gaps if set', { buffered: [{start: 0, end: 10}, {start: 30, end: 40}], start: 5, waitingAt: 10, - jumpLargeGaps: true, - expectEvent: true, expectedEndTime: 30, }); @@ -905,8 +845,6 @@ describe('Playhead', () => { [{start: 0, end: 10}, {start: 30, end: 40}, {start: 50, end: 60}], start: 5, waitingAt: 10, - jumpLargeGaps: true, - expectEvent: true, expectedEndTime: 30, }); @@ -915,20 +853,8 @@ describe('Playhead', () => { [{start: 0, end: 10}, {start: 20, end: 30}, {start: 50, end: 60}], start: 24, waitingAt: 30, - jumpLargeGaps: true, - expectEvent: true, expectedEndTime: 50, }); - - playingTest('won\'t jump gaps when preventDefault() is called', { - buffered: [{start: 0, end: 10}, {start: 30, end: 40}], - start: 5, - waitingAt: 10, - jumpLargeGaps: true, - preventDefault: true, - expectEvent: true, - expectedEndTime: 10, - }); }); // with large gaps /** @@ -941,20 +867,12 @@ describe('Playhead', () => { video.currentTime = data.start; video.readyState = HTMLMediaElement.HAVE_ENOUGH_DATA; - onEvent.and.callFake((event) => { - if (data.preventDefault) { - event.preventDefault(); - } - }); - - config.jumpLargeGaps = !!data.jumpLargeGaps; playhead = new shaka.media.MediaSourcePlayhead( video, manifest, config, /* startTime= */ data.start, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); jasmine.clock().tick(500); for (let time = data.start; time < data.waitingAt; time++) { @@ -975,14 +893,11 @@ describe('Playhead', () => { expect(video.currentTime).toBe(time + 0.4); } - expect(onEvent).not.toHaveBeenCalled(); - video.currentTime = data.waitingAt; video.readyState = HTMLMediaElement.HAVE_CURRENT_DATA; video.on['waiting'](); jasmine.clock().tick(500); - expect(onEvent).toHaveBeenCalledTimes(data.expectEvent ? 1 : 0); expect(video.currentTime).toBe(data.expectedEndTime); }); } @@ -995,7 +910,6 @@ describe('Playhead', () => { start: 4, seekTo: 14, expectedEndTime: 14, - expectEvent: false, }); seekTest('will jump when seeking into gap', { @@ -1003,7 +917,6 @@ describe('Playhead', () => { start: 3, seekTo: 10.4, expectedEndTime: 11, - expectEvent: false, }); seekTest('won\'t jump multiple buffers', { @@ -1012,7 +925,6 @@ describe('Playhead', () => { start: 3, seekTo: 10.4, expectedEndTime: 11, - expectEvent: false, }); seekTest('will jump into last range with seeking', { @@ -1021,7 +933,6 @@ describe('Playhead', () => { start: 3, seekTo: 20.5, expectedEndTime: 21, - expectEvent: false, }); seekTest('treats large gaps as small if playhead near end', { @@ -1029,36 +940,15 @@ describe('Playhead', () => { start: 3, seekTo: 29.2, expectedEndTime: 30, - expectEvent: false, }); }); // with small gaps describe('with large gaps', () => { - seekTest('will raise event', { - buffered: [{start: 0, end: 10}, {start: 30, end: 40}], - start: 5, - seekTo: 12, - expectedEndTime: 12, - expectEvent: true, - }); - seekTest('will jump large gaps', { buffered: [{start: 0, end: 10}, {start: 30, end: 40}], start: 5, seekTo: 12, - jumpLargeGaps: true, expectedEndTime: 30, - expectEvent: true, - }); - - seekTest('won\'t jump if preventDefault() is called', { - buffered: [{start: 0, end: 10}, {start: 30, end: 40}], - start: 5, - seekTo: 12, - jumpLargeGaps: true, - preventDefault: true, - expectedEndTime: 12, - expectEvent: true, }); }); // with large gaps }); // with buffered seeks @@ -1072,7 +962,6 @@ describe('Playhead', () => { start: 3, seekTo: 22, expectedEndTime: 22, - expectEvent: false, }); // Seeking to the beginning is considered an unbuffered seek even if @@ -1083,7 +972,6 @@ describe('Playhead', () => { start: 4, seekTo: 0, expectedEndTime: 0.2, - expectEvent: false, }); seekTest('will jump when seeking into gap', { @@ -1093,7 +981,6 @@ describe('Playhead', () => { start: 3, seekTo: 30.2, expectedEndTime: 31, - expectEvent: false, }); seekTest('will jump when seeking to the end of a range', { @@ -1103,7 +990,6 @@ describe('Playhead', () => { start: 3, seekTo: 30, expectedEndTime: 31, - expectEvent: false, }); seekTest('won\'t jump when past end', { @@ -1113,7 +999,6 @@ describe('Playhead', () => { start: 3, seekTo: 34, expectedEndTime: 34, - expectEvent: false, }); seekTest('won\'t jump when seeking backwards into buffered range', { @@ -1123,7 +1008,6 @@ describe('Playhead', () => { start: 24, seekTo: 4, expectedEndTime: 4, - expectEvent: false, }); seekTest('will wait to jump when seeking backwards', { @@ -1134,7 +1018,6 @@ describe('Playhead', () => { start: 24, seekTo: 4, expectedEndTime: 4, - expectEvent: false, }); seekTest('will jump when seeking backwards into gap', { @@ -1144,7 +1027,6 @@ describe('Playhead', () => { start: 24, seekTo: 1.6, expectedEndTime: 2, - expectEvent: false, }); }); // with small gaps @@ -1154,19 +1036,7 @@ describe('Playhead', () => { newBuffered: [{start: 20, end: 30}], start: 25, seekTo: 0, - jumpLargeGaps: true, expectedEndTime: 20, - expectEvent: true, - }); - - seekTest('will raise event', { - // [0-10], [20-30], [40-50] - buffered: [{start: 0, end: 10}], - newBuffered: [{start: 20, end: 30}, {start: 40, end: 50}], - start: 3, - seekTo: 32, - expectedEndTime: 32, - expectEvent: true, }); seekTest('will jump large gaps', { @@ -1176,20 +1046,6 @@ describe('Playhead', () => { start: 3, seekTo: 32, expectedEndTime: 40, - jumpLargeGaps: true, - expectEvent: true, - }); - - seekTest('will jump large gaps', { - // [0-10], [20-30], [40-50] - buffered: [{start: 0, end: 10}], - newBuffered: [{start: 20, end: 30}, {start: 40, end: 50}], - start: 3, - seekTo: 32, - expectedEndTime: 32, - jumpLargeGaps: true, - preventDefault: true, - expectEvent: true, }); }); // with large gaps }); // with unbuffered seeks @@ -1200,17 +1056,14 @@ describe('Playhead', () => { video.currentTime = 12; video.readyState = HTMLMediaElement.HAVE_ENOUGH_DATA; - config.jumpLargeGaps = true; playhead = new shaka.media.MediaSourcePlayhead( video, manifest, config, /* startTime= */ 12, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); jasmine.clock().tick(500); - expect(onEvent).not.toHaveBeenCalled(); // Append a segment before seeking. playhead.notifyOfBufferingChange(); @@ -1249,14 +1102,12 @@ describe('Playhead', () => { }, }); - config.jumpLargeGaps = true; playhead = new shaka.media.MediaSourcePlayhead( video, manifest, config, /* startTime= */ 0, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); playhead.notifyOfBufferingChange(); jasmine.clock().tick(500); @@ -1272,14 +1123,12 @@ describe('Playhead', () => { video.readyState = HTMLMediaElement.HAVE_ENOUGH_DATA; video.paused = true; - config.jumpLargeGaps = true; playhead = new shaka.media.MediaSourcePlayhead( video, manifest, config, /* startTime= */ 5, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); playhead.notifyOfBufferingChange(); jasmine.clock().tick(500); @@ -1297,14 +1146,12 @@ describe('Playhead', () => { video.paused = true; video.autoplay = true; - config.jumpLargeGaps = true; playhead = new shaka.media.MediaSourcePlayhead( video, manifest, config, /* startTime= */ 0, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); playhead.notifyOfBufferingChange(); jasmine.clock().tick(500); @@ -1322,14 +1169,12 @@ describe('Playhead', () => { video.paused = true; video.autoplay = false; - config.jumpLargeGaps = true; playhead = new shaka.media.MediaSourcePlayhead( video, manifest, config, /* startTime= */ 0, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); playhead.notifyOfBufferingChange(); jasmine.clock().tick(500); @@ -1348,23 +1193,14 @@ describe('Playhead', () => { video.currentTime = data.start; video.readyState = HTMLMediaElement.HAVE_ENOUGH_DATA; - onEvent.and.callFake((event) => { - if (data.preventDefault) { - event.preventDefault(); - } - }); - - config.jumpLargeGaps = !!data.jumpLargeGaps; playhead = new shaka.media.MediaSourcePlayhead( video, manifest, config, /* startTime= */ data.start, - Util.spyFunc(onSeek), - Util.spyFunc(onEvent)); + Util.spyFunc(onSeek)); jasmine.clock().tick(500); - expect(onEvent).not.toHaveBeenCalled(); // Seek to the given position and update ready state. video.currentTime = data.seekTo; @@ -1396,7 +1232,6 @@ describe('Playhead', () => { jasmine.clock().tick(250); } - expect(onEvent).toHaveBeenCalledTimes(data.expectEvent ? 1 : 0); expect(video.currentTime).toBe(data.expectedEndTime); }); } diff --git a/test/media/streaming_engine_integration.js b/test/media/streaming_engine_integration.js index 84768a1440..37c1acb16b 100644 --- a/test/media/streaming_engine_integration.js +++ b/test/media/streaming_engine_integration.js @@ -213,8 +213,7 @@ describe('StreamingEngine', () => { manifest, config, /* startTime= */ null, - onSeek, - shaka.test.Util.spyFunc(onEvent)); + onSeek); } function setupManifest( @@ -405,7 +404,6 @@ describe('StreamingEngine', () => { // TODO: Consider also adding tests for missing frames. describe('gap jumping', () => { it('jumps small gaps at the beginning', async () => { - config.smallGapLimit = 5; await setupGappyContent(/* gapAtStart= */ 1, /* dropSegment= */ false); // Let's go! @@ -421,8 +419,6 @@ describe('StreamingEngine', () => { }); it('jumps large gaps at the beginning', async () => { - config.smallGapLimit = 1; - config.jumpLargeGaps = true; await setupGappyContent(/* gapAtStart= */ 5, /* dropSegment= */ false); // Let's go! @@ -438,7 +434,6 @@ describe('StreamingEngine', () => { }); it('jumps small gaps in the middle', async () => { - config.smallGapLimit = 20; await setupGappyContent(/* gapAtStart= */ 0, /* dropSegment= */ true); // Let's go! @@ -453,11 +448,9 @@ describe('StreamingEngine', () => { await waiter.timeoutAfter(60).waitUntilPlayheadReaches(video, 23); // Should be close enough to still have the gap buffered. expect(video.buffered.length).toBe(2); - expect(onEvent).not.toHaveBeenCalled(); }); it('jumps large gaps in the middle', async () => { - config.jumpLargeGaps = true; await setupGappyContent(/* gapAtStart= */ 0, /* dropSegment= */ true); // Let's go! @@ -472,37 +465,6 @@ describe('StreamingEngine', () => { await waiter.timeoutAfter(60).waitUntilPlayheadReaches(video, 23); // Should be close enough to still have the gap buffered. expect(video.buffered.length).toBe(2); - expect(onEvent).toHaveBeenCalled(); - }); - - it('won\'t jump large gaps with preventDefault()', async () => { - config.jumpLargeGaps = true; - await setupGappyContent(/* gapAtStart= */ 0, /* dropSegment= */ true); - - onEvent.and.callFake((event) => { - event.preventDefault(); - }); - - // Let's go! - streamingEngine.switchVariant(variant); - await streamingEngine.start(); - - await waiter.timeoutAfter(5).waitForEvent(video, 'loadeddata'); - - let seekCount = 0; - eventManager.listen(video, 'seeking', () => { - seekCount++; - }); - - video.currentTime = 8; - video.play(); - - await shaka.test.Util.delay(5); - - // Edge somehow plays _into_ the gap, and Xbox One plays _through_ the - // gap. Just make sure _we_ don't jump the gap by seeking. One seek is - // required to start playback at time 8. - expect(seekCount).toBe(1); }); /** diff --git a/test/media/time_ranges_utils_unit.js b/test/media/time_ranges_utils_unit.js index 6fefc1b190..1086e3dde2 100644 --- a/test/media/time_ranges_utils_unit.js +++ b/test/media/time_ranges_utils_unit.js @@ -22,11 +22,6 @@ describe('TimeRangesUtils', () => { expect(TimeRangesUtils.isBuffered(b, 13)).toBe(true); }); - it('returns buffered when having a small gap', () => { - const b = createFakeBuffered([{start: 10, end: 20}]); - expect(TimeRangesUtils.isBuffered(b, 9, 1)).toBe(true); - }); - // Ranges: [10-20], [30-40], [50-60] defineTest('returns false when before range', {time: 3, expected: false}); defineTest('returns true inside first range', {time: 12, expected: true}); diff --git a/test/player_external.js b/test/player_external.js index 887aaa8273..24f1cd8bc8 100644 --- a/test/player_external.js +++ b/test/player_external.js @@ -106,12 +106,6 @@ describe('Player', () => { player.configure('manifest.dash.clockSyncUri', 'https://shaka-player-demo.appspot.com/time.txt'); - // Make sure we don't get stuck on gaps that only appear in some - // browsers (Safari, Firefox). - // TODO(https://github.com/shaka-project/shaka-player/issues/1702): - // Is this necessary because of a bug in Shaka Player? - player.configure('streaming.jumpLargeGaps', true); - // Add asset-specific configuration. player.configure(asset.getConfiguration());