From 551d2d7baea911658c77767116f5948f0c376527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 6 Feb 2020 19:34:13 +0100 Subject: [PATCH] Disable video when the media element is AUDIO (#2371) Closes #2246 Backported to v2.5.x Change-Id: Ia32d46409f7b90ec5b7494c1682c79a5c969bc55 --- lib/player.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/player.js b/lib/player.js index 472d6dc2ae..cdf52965d4 100644 --- a/lib/player.js +++ b/lib/player.js @@ -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); }; @@ -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);