Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support strms #548

Merged
merged 9 commits into from
Apr 26, 2022
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])
neilsb marked this conversation as resolved.
Show resolved Hide resolved
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