From 53dbbf21ca0397ff2f81c53167ba38d86dc9cd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 18 Apr 2023 18:59:03 +0200 Subject: [PATCH] fix: Fix selectVariantsByLabel using src= (#5154) --- lib/player.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/player.js b/lib/player.js index 6558945dbce..aa141b8f98a 100644 --- a/lib/player.js +++ b/lib/player.js @@ -4282,6 +4282,19 @@ shaka.Player = class extends shaka.util.FakeEventTarget { firstVariantWithLabel.language, '', 0, label); this.chooseVariantAndSwitch_(); + } else if (this.video_ && this.video_.audioTracks) { + const audioTracks = Array.from(this.video_.audioTracks); + + let trackMatch = null; + + for (const audioTrack of audioTracks) { + if (audioTrack.label == label) { + trackMatch = audioTrack; + } + } + if (trackMatch) { + this.switchHtml5Track_(trackMatch); + } } }