ensure selectedSubtitle is valid before using - fixes crash on line 87

This commit is contained in:
Charles Ewert 2023-04-19 18:55:31 -04:00
parent b91b2c582d
commit 089708c6d9

View File

@ -84,17 +84,18 @@ function setupSubtitle(video, subtitles, subtitle_idx = -1) as integer
selectedSubtitle = subtitles[subtitleSelIdx] selectedSubtitle = subtitles[subtitleSelIdx]
if selectedSubtitle.IsEncoded if isValid(selectedSubtitle) and isValid(selectedSubtitle.IsEncoded)
' With encoded subtitles, turn off captions if selectedSubtitle.IsEncoded
video.globalCaptionMode = "Off" ' With encoded subtitles, turn off captions
else video.globalCaptionMode = "Off"
' If this is a text-based subtitle, set relevant settings for roku captions else
video.globalCaptionMode = "On" ' If this is a text-based subtitle, set relevant settings for roku captions
video.subtitleTrack = video.availableSubtitleTracks[availSubtitleTrackIdx(video, subtitleSelIdx)].TrackName video.globalCaptionMode = "On"
video.subtitleTrack = video.availableSubtitleTracks[availSubtitleTrackIdx(video, subtitleSelIdx)].TrackName
end if
end if end if
return subtitleSelIdx return subtitleSelIdx
end function end function
' The subtitle index on the server differs from the index we track locally ' The subtitle index on the server differs from the index we track locally