diff --git a/docs/tutorials/basic-usage.md b/docs/tutorials/basic-usage.md index 64caac8bb..29eddae9c 100644 --- a/docs/tutorials/basic-usage.md +++ b/docs/tutorials/basic-usage.md @@ -3,11 +3,11 @@ Basic usage of Shaka Player is very easy: 1. Start with {@tutorial welcome} and compile the library. -2. Create a simple HTML page with a video element. +2. Create a simple HTML page with a video or audio element. 3. In your application's JavaScript: 1. Install Shaka's polyfills. 2. Check for browser support. - 3. Create a Player object to wrap the video element. + 3. Create a Player object to wrap the media element. 4. Listen for errors. 5. Load a manifest. diff --git a/lib/player.js b/lib/player.js index 64134ea6f..0a2b915ac 100644 --- a/lib/player.js +++ b/lib/player.js @@ -50,8 +50,8 @@ goog.require('shaka.util.StreamUtils'); /** * Construct a Player. * - * @param {HTMLMediaElement=} video If provided, this is equivalent to calling - * attach(video, true) immediately after construction. + * @param {HTMLMediaElement=} mediaElem If provided, this is equivalent to + * calling attach(mediaElem, true) immediately after construction. * @param {function(shaka.Player)=} dependencyInjector Optional callback * which is called to inject mocks into the Player. Used for testing. * @@ -61,7 +61,7 @@ goog.require('shaka.util.StreamUtils'); * @extends {shaka.util.FakeEventTarget} * @export */ -shaka.Player = function(video, dependencyInjector) { +shaka.Player = function(mediaElem, dependencyInjector) { shaka.util.FakeEventTarget.call(this); /** @private {HTMLMediaElement} */ @@ -193,8 +193,8 @@ shaka.Player = function(video, dependencyInjector) { this.networkingEngine_ = this.createNetworkingEngine(); - if (video) { - this.attach(video, true /* initializeMediaSource */); + if (mediaElem) { + this.attach(mediaElem, true /* initializeMediaSource */); } /** @private {!shaka.util.Destroyer} */ @@ -523,7 +523,7 @@ shaka.Player.probeSupport = function() { * After calling attach, the media element is owned by the Player and should not * be used for other purposes until detach or destroy() are called. * - * @param {!HTMLMediaElement} video + * @param {!HTMLMediaElement} mediaElem * @param {boolean=} initializeMediaSource If true, start initializing * MediaSource right away. This can improve load() latency for * MediaSource-based playbacks. Defaults to true. @@ -535,7 +535,8 @@ shaka.Player.probeSupport = function() { * media element. * @export */ -shaka.Player.prototype.attach = async function(video, initializeMediaSource) { +shaka.Player.prototype.attach = + async function(mediaElem, initializeMediaSource) { if (initializeMediaSource === undefined) { initializeMediaSource = true; } @@ -544,8 +545,8 @@ shaka.Player.prototype.attach = async function(video, initializeMediaSource) { await this.detach(); } - this.video_ = video; - goog.asserts.assert(video, 'Cannot attach to a null media element!'); + this.video_ = mediaElem; + goog.asserts.assert(mediaElem, 'Cannot attach to a null media element!'); // Listen for video errors. this.eventManager_.listen(this.video_, 'error',