Skip to content

Commit

Permalink
Merge pull request #1632 from 1hitsong/subtitleTurnOffBug
Browse files Browse the repository at this point in the history
Prevent unneeded video stop/start when turning off text subtitles
  • Loading branch information
1hitsong authored Jan 12, 2024
2 parents 5776339 + d93520b commit 5854b78
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions components/manager/ViewCreator.bs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ 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
exit for
end if
end for

if LCase(m.selectedSubtitle.track.description) = "none"
m.view.globalCaptionMode = "Off"
m.view.subtitleTrack = ""
Expand Down
13 changes: 11 additions & 2 deletions components/video/VideoPlayerView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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&)
Expand Down
1 change: 1 addition & 0 deletions components/video/VideoPlayerView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<field id="PlaySessionId" type="string" />
<field id="Subtitles" type="array" />
<field id="SelectedSubtitle" type="integer" value="-2" alwaysNotify="true" />
<field id="previousSubtitleWasEncoded" type="boolean" />
<field id="container" type="string" />
<field id="directPlaySupported" type="boolean" />
<field id="systemOverlay" type="boolean" value="false" />
Expand Down

0 comments on commit 5854b78

Please sign in to comment.