Skip to content

Commit

Permalink
Support strms (#548)
Browse files Browse the repository at this point in the history
Authored-by: @whiteowl3
  • Loading branch information
whiteowl3 authored Apr 26, 2022
1 parent 8ed66d1 commit be1d4a5
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions source/VideoPlayer.brs
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,57 @@ sub AddVideoContent(video, mediaSourceId, audio_stream_idx = 1, subtitle_idx = -
video.SelectedSubtitle = -1

video.directPlaySupported = playbackInfo.MediaSources[0].SupportsDirectPlay

fully_external = false
if video.directPlaySupported
params.append({
"Static": "true",
"Container": video.container,
"PlaySessionId": video.PlaySessionId,
"AudioStreamIndex": audio_stream_idx
})
if mediaSourceId <> ""
params.MediaSourceId = mediaSourceId
protocol = LCase(playbackInfo.MediaSources[0].Protocol)
if protocol <> "file"
uriRegex = CreateObject("roRegex", "^(.*:)//([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)$", "")
uri = uriRegex.Match(playbackinfo.MediaSources[0].Path)
' proto $1, host $2, port $3, the-rest $4
localhost = CreateObject("roRegex", "^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$", "i")
' https://stackoverflow.com/questions/8426171/what-regex-will-match-all-loopback-addresses
if localhost.isMatch(uri[2])
' if the domain of the URI is local to the server,
' create a new URI by appending the received path to the server URL
' later we will substitute the users provided URL for this case
video.content.url = buildURL(uri[4])
else
fully_external = true
video.content.url = playbackinfo.MediaSources[0].Path
end if
else:
params.append({
"Static": "true",
"Container": video.container,
"PlaySessionId": video.PlaySessionId,
"AudioStreamIndex": audio_stream_idx
})
if mediaSourceId <> ""
params.MediaSourceId = mediaSourceId
end if
video.content.url = buildURL(Substitute("Videos/{0}/stream", video.id), params)

end if
video.content.url = buildURL(Substitute("Videos/{0}/stream", video.id), params)
video.isTranscoded = false
video.audioTrack = (audio_stream_idx + 1).ToStr() ' Roku's track indexes count from 1. Our index is zero based
else
' If server does not provide a transcode URL, display a message to the user
if playbackInfo.MediaSources[0].TranscodingUrl = invalid
' If server does not provide a transcode URL, display a message to the user
m.global.sceneManager.callFunc("userMessage", tr("Error Getting Playback Information"), tr("An error was encountered while playing this item. Server did not provide required transcoding data."))
video.content = invalid
return
end if

' Get transcoding reason
video.transcodeReasons = getTranscodeReasons(playbackInfo.MediaSources[0].TranscodingUrl)

video.content.url = buildURL(playbackInfo.MediaSources[0].TranscodingUrl)
video.isTranscoded = true
end if

video.content = authorize_request(video.content)
video.content.setCertificatesFile("common:/certs/ca-bundle.crt")
video.audioTrack = (audio_stream_idx + 1).ToStr() ' Roku's track indexes count from 1. Our index is zero based

if not fully_external
video.content = authorize_request(video.content)
end if

end sub

Expand All @@ -156,8 +176,6 @@ function getTranscodeReasons(url as string) as object
return []
end function



'Opens dialog asking user if they want to resume video or start playback over
function startPlayBackOver(time as longinteger) as integer
if m.scene.focusedChild.overhangTitle = "Home"
Expand Down

0 comments on commit be1d4a5

Please sign in to comment.