From f0e21417375e7a26ad9cc6cdc4158812169d18b9 Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Fri, 15 Apr 2022 11:32:17 +0300 Subject: [PATCH] add prefix to embedded track ids --- src/HTMLVideo/HTMLVideo.js | 12 ++++++------ src/YouTubeVideo/YouTubeVideo.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/HTMLVideo/HTMLVideo.js b/src/HTMLVideo/HTMLVideo.js index 2878c01..4ac2100 100644 --- a/src/HTMLVideo/HTMLVideo.js +++ b/src/HTMLVideo/HTMLVideo.js @@ -173,7 +173,7 @@ function HTMLVideo(options) { return Array.from(videoElement.textTracks) .map(function(track, index) { return Object.freeze({ - id: String(index), + id: 'EMBEDDED_' + String(index), lang: track.language, label: track.label, origin: 'EMBEDDED', @@ -189,7 +189,7 @@ function HTMLVideo(options) { return Array.from(videoElement.textTracks) .reduce(function(result, track, index) { if (result === null && track.mode === 'showing') { - return String(index); + return 'EMBEDDED_' + String(index); } return result; @@ -238,7 +238,7 @@ function HTMLVideo(options) { return hls.audioTracks .map(function(track) { return Object.freeze({ - id: String(track.id), + id: 'EMBEDDED_' + String(track.id), lang: typeof track.lang === 'string' && track.lang.length > 0 ? track.lang : @@ -263,7 +263,7 @@ function HTMLVideo(options) { return null; } - return String(hls.audioTrack); + return 'EMBEDDED_' + String(hls.audioTrack); } case 'volume': { if (destroyed || videoElement.volume === null || !isFinite(videoElement.volume)) { @@ -371,7 +371,7 @@ function HTMLVideo(options) { if (stream !== null) { Array.from(videoElement.textTracks) .forEach(function(track, index) { - track.mode = String(index) === propValue ? 'showing' : 'disabled'; + track.mode = 'EMBEDDED_' + String(index) === propValue ? 'showing' : 'disabled'; }); var selecterdSubtitlesTrack = getProp('subtitlesTracks') .find(function(track) { @@ -449,7 +449,7 @@ function HTMLVideo(options) { .find(function(track) { return track.id === propValue; }); - hls.audioTrack = selecterdAudioTrack ? parseInt(selecterdAudioTrack.id, 10) : -1; + hls.audioTrack = selecterdAudioTrack ? parseInt(selecterdAudioTrack.id.split('_').pop(), 10) : -1; if (selecterdAudioTrack) { events.emit('audioTrackLoaded', selecterdAudioTrack); } diff --git a/src/YouTubeVideo/YouTubeVideo.js b/src/YouTubeVideo/YouTubeVideo.js index f13d11c..359ce20 100644 --- a/src/YouTubeVideo/YouTubeVideo.js +++ b/src/YouTubeVideo/YouTubeVideo.js @@ -243,7 +243,7 @@ function YouTubeVideo(options) { }) .map(function(track, index) { return Object.freeze({ - id: String(index), + id: 'EMBEDDED_' + String(index), lang: track.languageCode, label: typeof track.displayName === 'string' ? track.displayName : track.languageCode, origin: 'EMBEDDED',