diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 877c0e37b2..876e302a07 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -1665,6 +1665,7 @@ shaka.media.MediaSourceEngine = class { if (shaka.media.Capabilities.isChangeTypeSupported()) { if (this.transmuxers_[contentType]) { this.transmuxers_[contentType].destroy(); + delete this.transmuxers_[contentType]; } if (transmuxer) { this.transmuxers_[contentType] = transmuxer; @@ -1867,8 +1868,8 @@ shaka.media.MediaSourceEngine = class { } } - const newCodec = MimeUtils.getCodecBase( - MimeUtils.getCodecs(newMimeType)); + const newAllCodecs = MimeUtils.getCodecs(newMimeType); + const newCodec = MimeUtils.getCodecBase(newAllCodecs); const newBasicType = MimeUtils.getBasicType(newMimeType); // Current/new codecs base and basic type match then no need to switch @@ -1876,10 +1877,15 @@ shaka.media.MediaSourceEngine = class { return false; } - if (this.config_.codecSwitchingStrategy === + let allowChangeType = true; + if (this.needSplitMuxedContent_ || (newAllCodecs.split(',').length && + transmuxer && !this.transmuxers_[contentType])) { + allowChangeType = false; + } + + if (allowChangeType && this.config_.codecSwitchingStrategy === shaka.config.CodecSwitchingStrategy.SMOOTH && - shaka.media.Capabilities.isChangeTypeSupported() && - !this.needSplitMuxedContent_) { + shaka.media.Capabilities.isChangeTypeSupported()) { await this.changeType(contentType, newMimeType, transmuxer); } else { if (transmuxer) {