Skip to content

Commit

Permalink
Disable video when the media element is AUDIO (#2371)
Browse files Browse the repository at this point in the history
Closes #2246

Backported to v2.5.x

Change-Id: Ia32d46409f7b90ec5b7494c1682c79a5c969bc55
  • Loading branch information
Álvaro Velad Galván authored and joeyparrish committed Mar 11, 2020
1 parent 8fc6771 commit 551d2d7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,13 @@ shaka.Player.prototype.onInitializeParser_ = async function(has, wants) {
has.mimeType);
}

this.parser_.configure(this.config_.manifest);
const manifestConfig =
shaka.util.ObjectUtils.cloneObject(this.config_.manifest);
// Don't read video segments if the player is attached to an audio element
if (wants.mediaElement && wants.mediaElement.nodeName === 'AUDIO') {
manifestConfig.disableVideo = true;
}
this.parser_.configure(manifestConfig);
};


Expand Down Expand Up @@ -2394,7 +2400,13 @@ shaka.Player.prototype.configure = function(config, value) {
*/
shaka.Player.prototype.applyConfig_ = function() {
if (this.parser_) {
this.parser_.configure(this.config_.manifest);
const manifestConfig =
shaka.util.ObjectUtils.cloneObject(this.config_.manifest);
// Don't read video segments if the player is attached to an audio element
if (this.video_ && this.video_.nodeName === 'AUDIO') {
manifestConfig.disableVideo = true;
}
this.parser_.configure(manifestConfig);
}
if (this.drmEngine_) {
this.drmEngine_.configure(this.config_.drm);
Expand Down

0 comments on commit 551d2d7

Please sign in to comment.