Skip to content

Commit

Permalink
Merge pull request #104 from jimdogx/viv-fix-forced-subs
Browse files Browse the repository at this point in the history
Fix forced subs
  • Loading branch information
1hitsong authored Dec 27, 2024
2 parents a282ace + 0905388 commit 8ae04a8
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 @@ -21,7 +21,8 @@ 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
m.LoadMetaDataTask = CreateObject("roSGNode", "LoadVideoContentTask")
Expand Down Expand Up @@ -518,6 +519,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 @@ -860,6 +865,11 @@ sub ReportPlayback(state = "update" as string)
m.bufferCheckTimer.duration = 30
end if

if inArray(["stop", "finished"], state) and isValid(m.originalClosedCaptionState)
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 8ae04a8

Please sign in to comment.