Merge pull request #1671 from 1hitsong/fixNoAudioStreamCrash

Fix no audio stream crash
This commit is contained in:
1hitsong 2024-01-27 12:07:45 -05:00 committed by GitHub
commit 20d2583daf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -248,7 +248,14 @@ function defaultSubtitleTrackFromVid(videoID) as integer
if not isValidAndNotEmpty(meta.json.MediaSources[0].MediaStreams) then return SubtitleSelection.none
subtitles = sortSubtitles(meta.id, meta.json.MediaSources[0].MediaStreams)
selectedAudioLanguage = meta.json.MediaSources[0].MediaStreams[m.top.selectedAudioStreamIndex].Language ?? ""
selectedAudioLanguage = ""
audioMediaStream = meta.json.MediaSources[0].MediaStreams[m.top.selectedAudioStreamIndex]
' Ensure audio media stream is valid before using language property
if isValid(audioMediaStream)
selectedAudioLanguage = audioMediaStream.Language ?? ""
end if
defaultTextSubs = defaultSubtitleTrack(subtitles["text"], selectedAudioLanguage, true) ' Find correct subtitle track (forced text)
if defaultTextSubs <> SubtitleSelection.none