Skip to content

Commit

Permalink
Fix forced subs
Browse files Browse the repository at this point in the history
  • Loading branch information
jimdogx committed Dec 17, 2024
1 parent 8a9ac75 commit 6306b4b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit 6306b4b

Please sign in to comment.