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 1/7] 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 27e02349c..95da82a26 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) { From 7aa5d285108167bcef71438068e79e73cbfd54d6 Mon Sep 17 00:00:00 2001 From: redSpoutnik <15638041+redSpoutnik@users.noreply.github.com> Date: Tue, 8 Oct 2019 21:45:57 +0200 Subject: [PATCH 2/7] Test correct function in getPlayerSubtitleOffset --- src/components/playback/playbackmanager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 04fb89b3d..13497e191 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -1667,7 +1667,7 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla self.getPlayerSubtitleOffset = function(player) { player = player || self._currentPlayer; - if (player.getPlayerSubtitleOffset) { + if (player.getSubtitleOffset) { return player.getSubtitleOffset(); } } From 029e015068bb8564fa858ec59390f2e50d9902ad Mon Sep 17 00:00:00 2001 From: redSpoutnik <15638041+redSpoutnik@users.noreply.github.com> Date: Thu, 10 Oct 2019 17:45:56 +0200 Subject: [PATCH 3/7] more readable statement to find showing textTrack --- src/components/htmlvideoplayer/plugin.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/htmlvideoplayer/plugin.js b/src/components/htmlvideoplayer/plugin.js index 95da82a26..79b135fda 100644 --- a/src/components/htmlvideoplayer/plugin.js +++ b/src/components/htmlvideoplayer/plugin.js @@ -581,9 +581,11 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa Array.from(videoElement.textTracks) .filter(function(trackElement) { // get showing .vtt textTacks - return (trackElement.mode === 'showing') || + var isVttTrackShowing = trackElement.mode === 'showing'; // get current .ass textTrack - (("textTrack" + customTrackIndex) === trackElement.id); + var isAssTrackShowing = ("textTrack" + customTrackIndex) === trackElement.id; + + return isVttTrackShowing || isAssTrackShowing; }) .forEach(function(trackElement) { From bccb1e6147cc9d06cf7f9041d79828bdd570da68 Mon Sep 17 00:00:00 2001 From: redSpoutnik <15638041+redSpoutnik@users.noreply.github.com> Date: Sun, 13 Oct 2019 14:10:51 +0200 Subject: [PATCH 4/7] Fix subtitle sync for .ass --- src/components/htmlvideoplayer/plugin.js | 45 ++++++++++++------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/components/htmlvideoplayer/plugin.js b/src/components/htmlvideoplayer/plugin.js index 79b135fda..41ddcf56f 100644 --- a/src/components/htmlvideoplayer/plugin.js +++ b/src/components/htmlvideoplayer/plugin.js @@ -575,35 +575,34 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa self.setSubtitleOffset = function(offset) { var offsetValue = parseFloat(offset); - var videoElement = self._mediaElement; - var mediaStreamTextTracks = getMediaStreamTextTracks(self._currentPlayOptions.mediaSource); - Array.from(videoElement.textTracks) - .filter(function(trackElement) { - // get showing .vtt textTacks - var isVttTrackShowing = trackElement.mode === 'showing'; - // get current .ass textTrack - var isAssTrackShowing = ("textTrack" + customTrackIndex) === trackElement.id; - - return isVttTrackShowing || isAssTrackShowing; - }) - .forEach(function(trackElement) { + // if .ass currently rendering + if(currentAssRenderer){ + updateCurrentTrackOffset(offsetValue); + } else { + var videoElement = self._mediaElement; + var mediaStreamTextTracks = getMediaStreamTextTracks(self._currentPlayOptions.mediaSource); - var track = customTrackIndex === -1 ? null : mediaStreamTextTracks.filter(function (t) { - return t.Index === customTrackIndex; - })[0]; + Array.from(videoElement.textTracks) + .filter(function(trackElement) { + // get showing .vtt textTacks + return trackElement.mode === 'showing'; + }) + .forEach(function(trackElement) { - if(track) { - offsetValue = updateCurrentTrackOffset(offsetValue); - var format = (track.Codec || '').toLowerCase(); - if (format !== 'ass' && format !== 'ssa') { + var track = customTrackIndex === -1 ? null : mediaStreamTextTracks.filter(function (t) { + return t.Index === customTrackIndex; + })[0]; + + if(track) { + offsetValue = updateCurrentTrackOffset(offsetValue); setVttSubtitleOffset(trackElement, offsetValue); + } else { + console.log("No available track, cannot apply offset : " + offsetValue); } - } else { - console.log("No available track, cannot apply offset : " + offsetValue); - } - }); + }); + } }; function updateCurrentTrackOffset(offsetValue) { From f6eedbb221b61382c4591f4d295885bd33f1c4a1 Mon Sep 17 00:00:00 2001 From: redSpoutnik <15638041+redSpoutnik@users.noreply.github.com> Date: Fri, 25 Oct 2019 18:21:38 +0200 Subject: [PATCH 5/7] Update src/components/htmlvideoplayer/plugin.js Co-Authored-By: dkanada --- src/components/htmlvideoplayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/htmlvideoplayer/plugin.js b/src/components/htmlvideoplayer/plugin.js index 41ddcf56f..ab4621538 100644 --- a/src/components/htmlvideoplayer/plugin.js +++ b/src/components/htmlvideoplayer/plugin.js @@ -584,7 +584,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa var mediaStreamTextTracks = getMediaStreamTextTracks(self._currentPlayOptions.mediaSource); Array.from(videoElement.textTracks) - .filter(function(trackElement) { + .filter(function(trackElement) { // get showing .vtt textTacks return trackElement.mode === 'showing'; }) From 608a3e3200d058aa30a4ead43a96ed8517f3478a Mon Sep 17 00:00:00 2001 From: redSpoutnik <15638041+redSpoutnik@users.noreply.github.com> Date: Fri, 25 Oct 2019 18:21:46 +0200 Subject: [PATCH 6/7] Update src/components/htmlvideoplayer/plugin.js Co-Authored-By: dkanada --- src/components/htmlvideoplayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/htmlvideoplayer/plugin.js b/src/components/htmlvideoplayer/plugin.js index ab4621538..d30389609 100644 --- a/src/components/htmlvideoplayer/plugin.js +++ b/src/components/htmlvideoplayer/plugin.js @@ -577,7 +577,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa var offsetValue = parseFloat(offset); // if .ass currently rendering - if(currentAssRenderer){ + if (currentAssRenderer){ updateCurrentTrackOffset(offsetValue); } else { var videoElement = self._mediaElement; From c30e6b56a36acab3fec915ddc5c5511f23479a4b Mon Sep 17 00:00:00 2001 From: redSpoutnik <15638041+redSpoutnik@users.noreply.github.com> Date: Fri, 25 Oct 2019 18:21:54 +0200 Subject: [PATCH 7/7] Update src/components/htmlvideoplayer/plugin.js Co-Authored-By: dkanada --- src/components/htmlvideoplayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/htmlvideoplayer/plugin.js b/src/components/htmlvideoplayer/plugin.js index d30389609..88a59a29e 100644 --- a/src/components/htmlvideoplayer/plugin.js +++ b/src/components/htmlvideoplayer/plugin.js @@ -594,7 +594,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa return t.Index === customTrackIndex; })[0]; - if(track) { + if (track) { offsetValue = updateCurrentTrackOffset(offsetValue); setVttSubtitleOffset(trackElement, offsetValue); } else {