diff --git a/lib/player.js b/lib/player.js index 758045255e..4957b7a9e3 100644 --- a/lib/player.js +++ b/lib/player.js @@ -1099,10 +1099,12 @@ shaka.Player.prototype.onInitializeMediaSourceEngine_ = async function( has, wants) { goog.asserts.assert( has.mediaElement, - 'We should have a media element when loading.'); + 'We should have a media element when initializing media source.'); goog.asserts.assert( has.mediaElement == wants.mediaElement, - '|has| and |wants| should have the same media element when loading.'); + '|has| and |wants| should have the same media element when ' + + 'initializing media source.'); + goog.asserts.assert( this.mediaSourceEngine_ == null, 'We should not have a media source engine yet.'); @@ -1142,18 +1144,19 @@ shaka.Player.prototype.onInitializeMediaSourceEngine_ = async function( */ shaka.Player.prototype.onInitializeParser_ = async function(has, wants) { goog.asserts.assert( - this.networkingEngine_, - 'Need networking engine to parse manifest.'); + has.mediaElement, + 'We should have a media element when initializing the parser.'); goog.asserts.assert( - this.config_, - 'Need player config to parse manifest.'); + has.mediaElement == wants.mediaElement, + '|has| and |wants| should have the same media element when ' + + 'initializing the parser.'); goog.asserts.assert( - has.mediaElement, - 'We should have a media element when loading.'); + this.networkingEngine_, + 'Need networking engine when initializing the parser.'); goog.asserts.assert( - has.mediaElement == wants.mediaElement, - '|has| and |wants| should have the same media element when loading.'); + this.config_, + 'Need player config when initializing the parser.'); // We are going to "lock-in" the factory, mime type, and uri since they are // what we are going to use to create our parser and parse the manifest. @@ -1161,7 +1164,9 @@ shaka.Player.prototype.onInitializeParser_ = async function(has, wants) { has.mimeType = wants.mimeType; has.uri = wants.uri; - goog.asserts.assert(has.uri, 'We should have an assert uri when parsing.'); + goog.asserts.assert( + has.uri, + 'We should have an asset uri when initializing the parsing.'); // Store references to things we asserted so that we don't need to reassert // them again later. @@ -1199,34 +1204,34 @@ shaka.Player.prototype.onInitializeParser_ = async function(has, wants) { * @private */ shaka.Player.prototype.onParseManifest_ = function(has, wants) { - goog.asserts.assert( - this.networkingEngine_, - 'Need networking engine to parse manifest.'); - goog.asserts.assert( - this.config_, - 'Need player config to parse manifest.'); - - goog.asserts.assert( - this.parser_, - '|this.parser_| should have been set in an earlier step.'); - goog.asserts.assert( has.factory == wants.factory, - '|has| and |wants| should have the same factory when loading.'); + '|has| and |wants| should have the same factory when parsing.'); goog.asserts.assert( has.mimeType == wants.mimeType, - '|has| and |wants| should have the same mime type when loading.'); + '|has| and |wants| should have the same mime type when parsing.'); goog.asserts.assert( has.uri == wants.uri, - '|has| and |wants| should have the same uri when loading.'); + '|has| and |wants| should have the same uri when parsing.'); goog.asserts.assert( has.uri, - '|has| should have a valid uri when parsing a manifest.'); + '|has| should have a valid uri when parsing.'); goog.asserts.assert( has.uri == this.assetUri_, '|has.uri| should match the cached asset uri.'); + goog.asserts.assert( + this.networkingEngine_, + 'Need networking engine to parse manifest.'); + goog.asserts.assert( + this.config_, + 'Need player config to parse manifest.'); + + goog.asserts.assert( + this.parser_, + '|this.parser_| should have been set in an earlier step.'); + // Store references to things we asserted so that we don't need to reassert // them again later. const assetUri = has.uri; @@ -1347,7 +1352,9 @@ shaka.Player.prototype.onInitializeDrm_ = async function(has, wants) { * * Loading is defined as: * - Attaching all playback-related listeners to the media element - * - Initializing all playback components + * - Initializing playback and observers + * - Initializing ABR Manager + * - Initializing Streaming Engine * - Starting playback at |wants.startTime| * * @param {shaka.routing.Payload} has @@ -1355,26 +1362,26 @@ shaka.Player.prototype.onInitializeDrm_ = async function(has, wants) { * @private */ shaka.Player.prototype.onLoad_ = async function(has, wants) { + goog.asserts.assert( + has.factory == wants.factory, + '|has| and |wants| should have the same factory when loading.'); + goog.asserts.assert( + has.mimeType == wants.mimeType, + '|has| and |wants| should have the same mime type when loading.'); + goog.asserts.assert( + has.uri == wants.uri, + '|has| and |wants| should have the same uri when loading.'); + goog.asserts.assert( has.mediaElement, 'We should have a media element when loading.'); - goog.asserts.assert( - has.mediaElement == wants.mediaElement, - '|has| and |wants| should have the same media element when loading.'); goog.asserts.assert( wants.startTimeOfLoad, '|wants| should tell us when the load was originally requested'); - // Copy over all the data from |wants| to |has| that we are going to use and - // therefore depend on. + // Since we are about to start playback, we will lock in the start time as + // something we are now depending on. has.startTime = wants.startTime; - has.factory = wants.factory; - has.mimeType = wants.mimeType; - has.uri = wants.uri; - - goog.asserts.assert( - has.uri, - 'We should have an assert uri when loading.'); // Store a reference to values in |has| after asserting so that closure will // know that they will still be non-null between calls to await.