Actually play a movie

This commit is contained in:
Nick Bisby 2019-01-30 22:56:15 -06:00
parent 8d8fac9b19
commit f9722fd279
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
5 changed files with 96 additions and 25 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.svg *.svg
jellyfin-roku.zip jellyfin-roku.zip
source/globals.brs

View File

@ -1,14 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<component name="ServerSelect" extends="Scene"> <component name="ServerSelect" extends="Scene">
<children>
<Label id="myLabel"
text="This is a placeholder for the server picker"
width="1280"
height="720"
horizAlign="center"
vertAlign="center"
/>
</children>
<!-- BrightScript Portion --> <!-- BrightScript Portion -->
<script type="text/brightscript" > <script type="text/brightscript" >
<![CDATA[ <![CDATA[
@ -18,13 +10,6 @@
function init() function init()
m.top.setFocus(true) m.top.setFocus(true)
m.myLabel = m.top.findNode("myLabel")
'Set the font size
m.myLabel.font.size=24
'Set the color to light blue
m.myLabel.color="0xf3f3f3FF"
'** '**
'** The full list of editable attributes can be located at: '** The full list of editable attributes can be located at:

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="VideoScene" extends="Scene">
<children>
<Video id="VideoPlayer" />
</children>
<script type="text/brightscript">
<![CDATA[
function init()
m.top.setFocus(true)
m.scene = m.top.findNode("VideoScene")
end function
]]>
</script>
</component>

View File

@ -1,21 +1,19 @@
'*************************************************************
'** Hello World example
'** Copyright (c) 2015 Roku, Inc. All rights reserved.
'** Use of the Roku Platform is subject to the Roku SDK Licence Agreement:
'** https://docs.roku.com/doc/developersdk/en-us
'*************************************************************
sub Main() sub Main()
print "in showChannelSGScreen"
'Indicate this is a Roku SceneGraph application' 'Indicate this is a Roku SceneGraph application'
globals()
screen = CreateObject("roSGScreen") screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort") m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port) screen.setMessagePort(m.port)
'todo - pick the scene based on if we need a server already
first_scene = "ServerSelect"
'Create a scene and load a component' 'Create a scene and load a component'
scene = screen.CreateScene("ServerSelect") m.scene = screen.CreateScene("VideoScene")
screen.show() screen.show()
player = VideoPlayer(get_var("video_id"))
while(true) while(true)
msg = wait(0, m.port) msg = wait(0, m.port)
msgType = type(msg) msgType = type(msg)
@ -25,3 +23,8 @@ sub Main()
end while end while
end sub end sub
function get_var(key as String)
return GetGlobalAA().Lookup(key)
end function

67
source/VideoPlayer.brs Normal file
View File

@ -0,0 +1,67 @@
function VideoPlayer(id)
content = VideoContent(id)
video = m.scene.findNode("VideoPlayer")
video.AddHeader("X-Emby-Authorization", build_auth())
if content.protocol = "https" then
video.setCertificatesFile("common:/certs/ca-bundle.crt")
end if
video.content = content
video.setFocus(true)
video.control = "play"
return video
end function
function VideoContent(id) as object
content = createObject("RoSGNode", "ContentNode")
content.title = "Loading..."
meta = VideoMetaData(id)
content.title = meta.Name
protocol = get_var("protocol")
hostname = get_var("hostname")
content.url = Substitute("{0}://{1}/emby/Videos/{2}/stream.mp4", protocol, hostname, id)
content.protocol = "https"
return content
end function
function VideoMetaData(id)
protocol = get_var("protocol")
hostname = get_var("hostname")
user_id = get_var("user_id")
url = Substitute("{0}://{1}/emby/Users/{2}/Items/{3}", protocol, hostname, user_id, id)
req = createObject("roUrlTransfer")
req.setCertificatesFile("common:/certs/ca-bundle.crt")
req.setUrl(url)
req.AddHeader("X-Emby-Authorization", build_auth())
json = ParseJson(req.GetToString())
return json
end function
function build_auth() as String
auth = "MediaBrowser"
auth = auth + " Client=" + Chr(34) + "Jellyfin Roku" + Chr(34)
auth = auth + ", Device=" + Chr(34) + "Roku Model" + Chr(34)
auth = auth + ", DeviceId=" + Chr(34) + "12345" + Chr(34)
auth = auth + ", Version=" + Chr(34) + "10.1.0" + Chr(34)
auth = auth + ", UserId=" + Chr(34) + get_var("user_id") + Chr(34)
auth = auth + ", Token=" + Chr(34) + get_var("user_token") + Chr(34)
return auth
end function