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,6 +84,7 @@ function setupSubtitle(video, subtitles, subtitle_idx = -1) as integer
selectedSubtitle = subtitles[subtitleSelIdx] selectedSubtitle = subtitles[subtitleSelIdx]
if isValid(selectedSubtitle) and isValid(selectedSubtitle.IsEncoded)
if selectedSubtitle.IsEncoded if selectedSubtitle.IsEncoded
' With encoded subtitles, turn off captions ' With encoded subtitles, turn off captions
video.globalCaptionMode = "Off" video.globalCaptionMode = "Off"
@ -92,9 +93,9 @@ function setupSubtitle(video, subtitles, subtitle_idx = -1) as integer
video.globalCaptionMode = "On" video.globalCaptionMode = "On"
video.subtitleTrack = video.availableSubtitleTracks[availSubtitleTrackIdx(video, subtitleSelIdx)].TrackName 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