From 6b058f8c098bb9b9bef9f83f85144ac776554f95 Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Fri, 15 Dec 2023 19:33:25 -0600 Subject: [PATCH] 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. --- .../ft-video-player/ft-video-player.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index dae1939f2e905..84582442b0efc 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -1410,6 +1410,14 @@ export default defineComponent({ const trackIndex = this.useDash ? 1 : 0 const tracks = this.player.textTracks() + + // visually and semantically disable any other enabled tracks + for (let i = 0; i < tracks.length; ++i) { + if (i !== trackIndex) { + tracks[i].mode = 'disabled' + } + } + if (tracks.length > trackIndex) { if (tracks[trackIndex].mode === 'showing') { tracks[trackIndex].mode = 'disabled' @@ -1868,19 +1876,16 @@ export default defineComponent({ captionList = this.captionHybridList } - for (const caption of this.sortCaptions(captionList)) { + this.sortCaptions(captionList).forEach((caption, i) => this.player.addRemoteTextTrack({ kind: 'subtitles', src: caption.url, srclang: caption.language_code, label: caption.label, - type: caption.type + type: caption.type, + default: i === 0 && this.enableSubtitlesByDefault }, true) - } - - if (this.enableSubtitlesByDefault) { - this.toggleCaptions() - } + ) }, toggleFullWindow: function () {