diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index dc078a6f93..bee0f01817 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -2052,6 +2052,22 @@ shaka.media.MediaSourceEngine = class { // Current/new codecs base and basic type match then no need to switch if (currentCodec === newCodec && currentBasicType === newBasicType) { + if (this.transmuxers_[contentType] && !transmuxer) { + this.transmuxers_[contentType].destroy(); + delete this.transmuxers_[contentType]; + } else if (!this.transmuxers_[contentType] && transmuxer) { + this.transmuxers_[contentType] = transmuxer; + } else if (transmuxer) { + // Compare if the transmuxer is different + if (this.transmuxers_[contentType] && + this.transmuxers_[contentType].transmux != transmuxer.transmux) { + this.transmuxers_[contentType].destroy(); + delete this.transmuxers_[contentType]; + this.transmuxers_[contentType] = transmuxer; + } else { + transmuxer.destroy(); + } + } return false; }