From 6306b4b642a8fb1faa34480a64f1078a5b9a9ba2 Mon Sep 17 00:00:00 2001 From: Jimi Date: Tue, 17 Dec 2024 11:14:48 -0700 Subject: [PATCH 1/3] Fix forced subs --- components/video/VideoPlayerView.bs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index fa788ee21..c404b272c 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -22,6 +22,7 @@ sub init() preferredSubtitle = m.global.queueManager.callFunc("getPreferredSubtitleTrack") m.top.SelectedSubtitle = isChainValid(preferredSubtitle, "StreamIndex") ? preferredSubtitle.StreamIndex : -1 + m.originalClosedCaptionState = invalid ' Load meta data m.LoadMetaDataTask = CreateObject("roSGNode", "LoadVideoContentTask") @@ -510,7 +511,7 @@ sub onVideoContentLoaded() ' Set subtitleTrack property if subs are natively supported by Roku selectedSubtitle = invalid for each subtitle in m.top.fullSubtitleData - if subtitle.Index = videoContent[0].selectedSubtitle + if subtitle.Index = videoContent[0].selectedSubtitle or subtitle.IsForced selectedSubtitle = subtitle exit for end if @@ -520,6 +521,10 @@ sub onVideoContentLoaded() availableSubtitleTrackIndex = availSubtitleTrackIdx(selectedSubtitle.Track.TrackName) if availableSubtitleTrackIndex <> -1 if not selectedSubtitle.IsEncoded + if selectedSubtitle.IsForced + ' If IsForced, make sure to remember the Roku global setting so we can set it back when the video is done playing. + m.originalClosedCaptionState = m.top.globalCaptionMode + end if m.top.globalCaptionMode = "On" m.top.subtitleTrack = m.top.availableSubtitleTracks[availableSubtitleTrackIndex].TrackName end if @@ -862,6 +867,11 @@ sub ReportPlayback(state = "update" as string) m.bufferCheckTimer.duration = 30 end if + if (state = "stop" or state = "finished") and m.originalClosedCaptionState <> invalid + m.top.globalCaptionMode = m.originalClosedCaptionState + m.originalClosedCaptionState = invalid + end if + ' Report playstate via worker task playstateTask = m.global.playstateTask playstateTask.setFields({ status: state, params: params }) From 01f40ca7e9483263e436fadc974c4bfda51a1258 Mon Sep 17 00:00:00 2001 From: Jimi Date: Fri, 27 Dec 2024 07:10:39 -0700 Subject: [PATCH 2/3] Init selected subtitle instead of additional check. --- components/video/VideoPlayerView.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index a5f3d5451..29809ea9b 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -21,7 +21,7 @@ sub init() } preferredSubtitle = m.global.queueManager.callFunc("getPreferredSubtitleTrack") - m.top.SelectedSubtitle = isChainValid(preferredSubtitle, "StreamIndex") ? preferredSubtitle.StreamIndex : -1 + m.top.SelectedSubtitle = isChainValid(preferredSubtitle, "StreamIndex") ? preferredSubtitle.StreamIndex : -2 m.originalClosedCaptionState = invalid ' Load meta data @@ -509,7 +509,7 @@ sub onVideoContentLoaded() ' Set subtitleTrack property if subs are natively supported by Roku selectedSubtitle = invalid for each subtitle in m.top.fullSubtitleData - if subtitle.Index = videoContent[0].selectedSubtitle or subtitle.IsForced + if subtitle.Index = videoContent[0].selectedSubtitle selectedSubtitle = subtitle exit for end if From 0905388b93a6bf07283f940164fbadf16e1202c8 Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Fri, 27 Dec 2024 09:35:15 -0500 Subject: [PATCH 3/3] Minor code style changes --- components/video/VideoPlayerView.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/video/VideoPlayerView.bs b/components/video/VideoPlayerView.bs index 29809ea9b..c54b245bf 100644 --- a/components/video/VideoPlayerView.bs +++ b/components/video/VideoPlayerView.bs @@ -865,7 +865,7 @@ sub ReportPlayback(state = "update" as string) m.bufferCheckTimer.duration = 30 end if - if (state = "stop" or state = "finished") and m.originalClosedCaptionState <> invalid + if inArray(["stop", "finished"], state) and isValid(m.originalClosedCaptionState) m.top.globalCaptionMode = m.originalClosedCaptionState m.originalClosedCaptionState = invalid end if