From c1e2f7aab5d06fe856e54a48b8596ca7e4bd2d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 12 Jun 2025 13:48:43 +0200 Subject: [PATCH] fix(HLS): Fix switching between muxed and alternate audios (#8741) Fixes https://github.com/shaka-project/shaka-player/issues/8737 --- lib/hls/hls_parser.js | 3 ++- lib/media/streaming_engine.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 131fff966..5bc19ca5e 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2670,7 +2670,8 @@ shaka.hls.HlsParser = class { if (type == ContentType.VIDEO || type == ContentType.AUDIO) { for (const otherStreamInfo of this.uriToStreamInfosMap_.values()) { - if (!otherStreamInfo.loadedOnce && otherStreamInfo.type == type) { + if (!otherStreamInfo.loadedOnce && otherStreamInfo.type == type && + !otherStreamInfo.stream.isAudioMuxedInVideo) { // To aid manifest filtering, assume before loading that all video // renditions have the same MIME type. (And likewise for audio.) otherStreamInfo.stream.mimeType = realStream.mimeType; diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index be5194f89..e4920338c 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -2980,6 +2980,7 @@ shaka.media.StreamingEngine = class { if (audioMediaState.segmentIterator) { audioMediaState.segmentIterator.resetToLastIndependent(); } + this.cancelUpdate_(audioMediaState); } const videoMediaState = this.mediaStates_.get(ContentType.VIDEO); if (videoMediaState) { @@ -2993,14 +2994,14 @@ shaka.media.StreamingEngine = class { if (videoMediaState.segmentIterator) { videoMediaState.segmentIterator.resetToLastIndependent(); } + this.cancelUpdate_(videoMediaState); } /** * @type {!Map} */ const streamsByType = new Map(); - if (this.currentVariant_.audio && - !this.currentVariant_.audio.isAudioMuxedInVideo) { + if (this.currentVariant_.audio) { streamsByType.set(ContentType.AUDIO, this.currentVariant_.audio); } if (this.currentVariant_.video) {