diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs index 722d8fe9a..41504b4d5 100644 --- a/source/VideoPlayer.brs +++ b/source/VideoPlayer.brs @@ -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 @@ -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"