Handle Missing Media Streams when displaying media info

This commit is contained in:
Neil Burrows 2022-04-26 17:35:40 +01:00
parent e9509a68c5
commit ddd5261bd5
2 changed files with 16 additions and 10 deletions

View File

@ -101,7 +101,15 @@ sub SetUpVideoOptions(streams)
for i = 0 to streams.Count() - 1
if streams[i].VideoType = "VideoFile"
videos.push({ "Title": streams[i].Name, "Description": tr("Video"), "Selected": m.top.selectedVideoStreamId = streams[i].id, "StreamID": streams[i].id, "video_codec": streams[i].mediaStreams[0].displayTitle })
codec = ""
if streams[i].mediaStreams <> invalid and streams[i].mediaStreams.Count() > 0 then codec = streams[i].mediaStreams[0].displayTitle
videos.push({
"Title": streams[i].Name,
"Description": tr("Video"),
"Selected": m.top.selectedVideoStreamId = streams[i].id,
"StreamID": streams[i].id,
"video_codec": codec
})
end if
end for

View File

@ -27,25 +27,23 @@ sub itemContentChanged()
m.top.findNode("star").visible = false
end if
videoIdx = invalid
audioIdx = invalid
if itemData.MediaStreams <> invalid
videoIdx = invalid
audioIdx = invalid
for i = 0 to itemData.MediaStreams.Count() - 1
if itemData.MediaStreams[i].Type = "Video" and videoIdx = invalid
videoIdx = i
m.top.findNode("video_codec").text = tr("Video") + ": " + itemData.mediaStreams[i].DisplayTitle
else if itemData.MediaStreams[i].Type = "Audio" and audioIdx = invalid
audioIdx = i
m.top.findNode("audio_codec").text = tr("Audio") + ": " + itemData.mediaStreams[i].DisplayTitle
end if
if videoIdx <> invalid and audioIdx <> invalid then exit for
end for
m.top.findNode("video_codec").text = tr("Video") + ": " + itemData.mediaStreams[videoIdx].DisplayTitle
m.top.findNode("audio_codec").text = tr("Audio") + ": " + itemData.mediaStreams[audioIdx].DisplayTitle
m.top.findNode("video_codec").visible = true
m.top.findNode("audio_codec").visible = true
else
m.top.findNode("video_codec").visible = false
m.top.findNode("audio_codec").visible = false
end if
m.top.findNode("video_codec").visible = videoIdx <> invalid
m.top.findNode("audio_codec").visible = audioIdx <> invalid
end sub
function getRuntime() as integer