Skip to content

Commit b540e4c

Browse files
committed
Fix double-selection issue when auto-generated & native tracks exist, & fix similar pre-existing bug
Also fixes pre-existing bug with pressing 'c' having the effect of multiple tracks (inaccurately) showing as selected.
1 parent 897d789 commit b540e4c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/renderer/components/ft-video-player/ft-video-player.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,14 @@ export default defineComponent({
14101410
const trackIndex = this.useDash ? 1 : 0
14111411

14121412
const tracks = this.player.textTracks()
1413+
1414+
// visually and semantically disable any other enabled tracks
1415+
for (let i = 0; i < tracks.length; ++i) {
1416+
if (i !== trackIndex && tracks[i].mode === 'showing') {
1417+
tracks[i].mode = 'disabled'
1418+
}
1419+
}
1420+
14131421
if (tracks.length > trackIndex) {
14141422
if (tracks[trackIndex].mode === 'showing') {
14151423
tracks[trackIndex].mode = 'disabled'
@@ -1868,19 +1876,16 @@ export default defineComponent({
18681876
captionList = this.captionHybridList
18691877
}
18701878

1871-
for (const caption of this.sortCaptions(captionList)) {
1879+
this.sortCaptions(captionList).forEach((caption, i) =>
18721880
this.player.addRemoteTextTrack({
18731881
kind: 'subtitles',
18741882
src: caption.url,
18751883
srclang: caption.language_code,
18761884
label: caption.label,
1877-
type: caption.type
1885+
type: caption.type,
1886+
default: i === 0 && this.enableSubtitlesByDefault
18781887
}, true)
1879-
}
1880-
1881-
if (this.enableSubtitlesByDefault) {
1882-
this.toggleCaptions()
1883-
}
1888+
)
18841889
},
18851890

18861891
toggleFullWindow: function () {

0 commit comments

Comments
 (0)