diff --git a/hls-video-element.js b/hls-video-element.js index c430608..df184fa 100644 --- a/hls-video-element.js +++ b/hls-video-element.js @@ -120,9 +120,11 @@ class HLSVideoElement extends MediaTracksMixin(CustomVideoElement) { }); this.audioTracks.addEventListener('change', () => { - const audioTrackId = [...this.audioTracks].find(t => t.enabled)?.id; - if (audioTrackId != null && audioTrackId != this.api.audioTrack) { - this.api.audioTrack = +audioTrackId; + // Cast to number, hls.js uses numeric id's. + const audioTrackId = +[...this.audioTracks].find(t => t.enabled)?.id; + const availableIds = this.api.audioTracks.map(t => t.id); + if (audioTrackId != this.api.audioTrack && availableIds.includes(audioTrackId)) { + this.api.audioTrack = audioTrackId; } }); diff --git a/package.json b/package.json index cf07a59..148c975 100644 --- a/package.json +++ b/package.json @@ -22,15 +22,15 @@ }, "dependencies": { "custom-media-element": "^1.0.0", - "hls.js": "^1.4.9", - "media-tracks": "^0.2.3" + "hls.js": "^1.4.12", + "media-tracks": "^0.2.4" + }, + "devDependencies": { + "wet-run": "^0.2.0" }, "keywords": [ "HLS", "video", "player" - ], - "devDependencies": { - "wet-run": "^0.2.0" - } + ] } diff --git a/yarn.lock b/yarn.lock index eed4ba0..f744b75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,15 +7,15 @@ custom-media-element@^1.0.0: resolved "https://registry.yarnpkg.com/custom-media-element/-/custom-media-element-1.0.0.tgz#6b04f62cb7187268ab2622251a52f7539de912eb" integrity sha512-wVruLAFUOtJuTaemcXPGlweGLI5efwUoctUQzMqSJRZdtetNQzrfy3CPF3daOJoJnq2OLY9Byknrv1+hruW+cw== -hls.js@^1.4.9: - version "1.4.9" - resolved "https://registry.yarnpkg.com/hls.js/-/hls.js-1.4.9.tgz#8b23b029cafda4b64ef1c5acd4f65c4f245103d7" - integrity sha512-i2BuNh7C7sd+wpW1V9p+P37KKCWNc6Ph/3BiPr+8nfJ7eZdtQQvSQUn2QwKU+7Fvc7b5BpS/lM6RJ3LUf+XbWg== +hls.js@^1.4.12: + version "1.4.12" + resolved "https://registry.yarnpkg.com/hls.js/-/hls.js-1.4.12.tgz#2022daa29d10c662387d80a5297f8330f8ef5ee2" + integrity sha512-1RBpx2VihibzE3WE9kGoVCtrhhDWTzydzElk/kyRbEOLnb1WIE+3ZabM/L8BqKFTCL3pUy4QzhXgD1Q6Igr1JA== -media-tracks@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/media-tracks/-/media-tracks-0.2.3.tgz#ba9a23c45e1ee1be2acdd580f985d25b9036fff9" - integrity sha512-h5HRl1tIyeV+aF59FAmHmxChmdM/Ewf/twpxZkRme1ny46owD24uTA0BmRuPoO+uzvE0lx9ZIkZj1TbXi2VCng== +media-tracks@^0.2.4: + version "0.2.4" + resolved "https://registry.yarnpkg.com/media-tracks/-/media-tracks-0.2.4.tgz#aee3bd69bdc8f246b44af5245f7b0a68d4c94540" + integrity sha512-P/TbDCYTFH5gxpQ6r99iabXOwjsFwzKRgK7wiwo64Ii6nHXYhHtwEP7A7ufmEKxkNCoHc4j3Z2hvs+lXL4wPeQ== playwright-core@^1.31.1: version "1.36.1"