From 2d91603d391e3eab205d9761b95f3c7bec08d1a5 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 15 Oct 2024 07:59:58 -0400 Subject: [PATCH] Prevent crash when there are no media streams (#1982) --- source/api/Items.bs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/api/Items.bs b/source/api/Items.bs index c7ba49899..3f6319437 100644 --- a/source/api/Items.bs +++ b/source/api/Items.bs @@ -37,8 +37,10 @@ function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioT params.EnableDirectPlay = false end if - if audioTrackIndex > -1 - selectedAudioStream = m.global.session.video.json.MediaStreams[audioTrackIndex] + myGLobal = m.global + + if audioTrackIndex > -1 and myGLobal.session.video.json.MediaStreams <> invalid + selectedAudioStream = myGLobal.session.video.json.MediaStreams[audioTrackIndex] if selectedAudioStream <> invalid params.AudioStreamIndex = audioTrackIndex @@ -62,7 +64,6 @@ function ItemPostPlaybackInfo(id as string, mediaSourceId = "" as string, audioT end for end if end if - end if end if