From d4f4bfc7411542acf3e9efe833aebed5f3001c99 Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:29:15 -0500 Subject: [PATCH 1/2] Prevent unneeded stop/start --- components/manager/ViewCreator.bs | 7 +++++++ components/video/VideoPlayerView.bs | 13 +++++++++++-- components/video/VideoPlayerView.xml | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/manager/ViewCreator.bs b/components/manager/ViewCreator.bs index ebee6b3a9..214712b45 100644 --- a/components/manager/ViewCreator.bs +++ b/components/manager/ViewCreator.bs @@ -99,6 +99,13 @@ sub processSubtitleSelection() ' The playbackData is now outdated and must be refreshed m.playbackData = invalid + ' Find previously selected subtitle and identify if it was encoded + for each item in m.view.fullSubtitleData + if item.index = m.view.selectedSubtitle + m.view.previousSubtitleWasEncoded = item.IsEncoded + end if + end for + if LCase(m.selectedSubtitle.track.description) = "none" m.view.globalCaptionMode = "Off" m.view.subtitleTrack = "" diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index c2a893061..9bc49fee4 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -256,8 +256,17 @@ end sub ' Event handler for when selectedSubtitle changes sub onSubtitleChange() - ' If the global caption mode is on, that means Roku can display the subtitles natively and doesn't need a video stop/start - if LCase(m.top.globalCaptionMode) = "on" then return + switchWithoutRefresh = true + + if m.top.SelectedSubtitle <> -1 + ' If the global caption mode is off, then Roku can't display the subtitles natively and needs a video stop/start + if LCase(m.top.globalCaptionMode) <> "on" then switchWithoutRefresh = false + end if + + ' If previous sustitle was encoded, then we need to a video stop/start to change subtitle content + if m.top.previousSubtitleWasEncoded then switchWithoutRefresh = false + + if switchWithoutRefresh then return ' Save the current video position m.global.queueManager.callFunc("setTopStartingPoint", int(m.top.position) * 10000000&) diff --git a/components/video/VideoPlayerView.xml b/components/video/VideoPlayerView.xml index e33724b00..bd35744de 100644 --- a/components/video/VideoPlayerView.xml +++ b/components/video/VideoPlayerView.xml @@ -7,6 +7,7 @@ + From d93520bab417e6541d1f7be72fa30ba2c243336a Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:52:04 -0500 Subject: [PATCH 2/2] Exit loop once match is found --- components/manager/ViewCreator.bs | 1 + 1 file changed, 1 insertion(+) diff --git a/components/manager/ViewCreator.bs b/components/manager/ViewCreator.bs index 214712b45..55b6275fc 100644 --- a/components/manager/ViewCreator.bs +++ b/components/manager/ViewCreator.bs @@ -103,6 +103,7 @@ sub processSubtitleSelection() for each item in m.view.fullSubtitleData if item.index = m.view.selectedSubtitle m.view.previousSubtitleWasEncoded = item.IsEncoded + exit for end if end for