Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

fix: audiotracks #41

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions hls-video-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down