From 8496b3d1f5441e34938e197a0686862f69fc6934 Mon Sep 17 00:00:00 2001 From: redSpoutnik <15638041+redSpoutnik@users.noreply.github.com> Date: Tue, 8 Oct 2019 21:16:33 +0200 Subject: [PATCH] Fix subtitle sync for .vtt --- src/components/htmlvideoplayer/plugin.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/htmlvideoplayer/plugin.js b/src/components/htmlvideoplayer/plugin.js index 27e02349c0..95da82a26b 100644 --- a/src/components/htmlvideoplayer/plugin.js +++ b/src/components/htmlvideoplayer/plugin.js @@ -580,18 +580,15 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa Array.from(videoElement.textTracks) .filter(function(trackElement) { - if (customTrackIndex === -1 ) { - // get showing .vtt textTacks - return trackElement.mode === 'showing'; - } else { - // get current .ass textTrack - return ("textTrack" + customTrackIndex) === trackElement.id; - } + // get showing .vtt textTacks + return (trackElement.mode === 'showing') || + // get current .ass textTrack + (("textTrack" + customTrackIndex) === trackElement.id); }) .forEach(function(trackElement) { - var track = mediaStreamTextTracks.filter(function(stream) { - return ("textTrack" + stream.Index) === trackElement.id; + var track = customTrackIndex === -1 ? null : mediaStreamTextTracks.filter(function (t) { + return t.Index === customTrackIndex; })[0]; if(track) {