From a76eacb624683e71c8add7e6c727b074a956a2ad Mon Sep 17 00:00:00 2001 From: Nick Bisby Date: Mon, 22 Apr 2019 00:09:16 -0500 Subject: [PATCH] Begin looking into audio solutions --- source/VideoPlayer.brs | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs index 4b898387..2541fa9d 100644 --- a/source/VideoPlayer.brs +++ b/source/VideoPlayer.brs @@ -22,12 +22,7 @@ function VideoContent(id) as object meta = ItemMetaData(id) content.title = meta.Name - container = meta.json.mediaSources[0].container - if container = invalid - container = "" - else if container = "m4v" or container = "mov" - container = "mp4" - end if + container = getContainerType(meta) content.url = buildURL(Substitute("Videos/{0}/stream", id), { Static: "true", @@ -39,6 +34,8 @@ function VideoContent(id) as object content.streamformat = container content.switchingStrategy = "" + ' todo - audioFormat is read only + content.audioFormat = getAudioFormat(meta) if server_is_https() then content.setCertificatesFile("common:/certs/ca-bundle.crt") @@ -46,3 +43,35 @@ function VideoContent(id) as object return content end function + +function getContainerType(meta as object) as string + if meta.json.mediaSources = invalid then return "" + + container = meta.json.mediaSources[0].container + if container = invalid + container = "" + else if container = "m4v" or container = "mov" + container = "mp4" + end if + + return container +end function + +function getAudioFormat(meta as object) as string + if meta.json.mediaSources = invalid then return "" + + audioInfo = getAudioInfo(meta) + if audioInfo.count() = 0 then return "" + return audioInfo[0].codec +end function + + +function getAudioInfo(meta as object) as object + results = [] + for each source in meta.json.mediaSources[0].mediaStreams + if source["type"] = "Audio" + results.push(source) + end if + end for + return results +end function