Skip to content

Commit

Permalink
Rename 'video' to 'mediaElem'.
Browse files Browse the repository at this point in the history
This emphasizes that both a <video> and <audio> elements can be used
in Shaka Player.

Closes #1555

Backported to v2.4.x

Change-Id: I2aa6e10b9ad7044588e1b418d938060aca333a2b
  • Loading branch information
TheModMaker authored and joeyparrish committed Oct 5, 2018
1 parent 94bd975 commit cdb3a56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/tutorials/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
19 changes: 10 additions & 9 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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)=} opt_dependencyInjector Optional callback
* which is called to inject mocks into the Player. Used for testing.
*
Expand All @@ -58,7 +58,7 @@ goog.require('shaka.util.StreamUtils');
* @extends {shaka.util.FakeEventTarget}
* @export
*/
shaka.Player = function(video, opt_dependencyInjector) {
shaka.Player = function(mediaElem, opt_dependencyInjector) {
shaka.util.FakeEventTarget.call(this);

/** @private {boolean} */
Expand Down Expand Up @@ -182,8 +182,8 @@ shaka.Player = function(video, opt_dependencyInjector) {

this.networkingEngine_ = this.createNetworkingEngine();

if (video) {
this.attach(video, true /* initializeMediaSource */);
if (mediaElem) {
this.attach(mediaElem, true /* initializeMediaSource */);
}
};
goog.inherits(shaka.Player, shaka.util.FakeEventTarget);
Expand Down Expand Up @@ -493,7 +493,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.
Expand All @@ -505,7 +505,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;
}
Expand All @@ -514,8 +515,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',
Expand Down

0 comments on commit cdb3a56

Please sign in to comment.