Actually play a movie
This commit is contained in:
parent
8d8fac9b19
commit
f9722fd279
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*.svg
|
||||
jellyfin-roku.zip
|
||||
source/globals.brs
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<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 -->
|
||||
<script type="text/brightscript" >
|
||||
<![CDATA[
|
||||
|
@ -18,13 +10,6 @@
|
|||
|
||||
function init()
|
||||
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:
|
15
components/videoplayer.xml
Normal file
15
components/videoplayer.xml
Normal 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>
|
|
@ -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()
|
||||
print "in showChannelSGScreen"
|
||||
'Indicate this is a Roku SceneGraph application'
|
||||
globals()
|
||||
|
||||
screen = CreateObject("roSGScreen")
|
||||
m.port = CreateObject("roMessagePort")
|
||||
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'
|
||||
scene = screen.CreateScene("ServerSelect")
|
||||
m.scene = screen.CreateScene("VideoScene")
|
||||
screen.show()
|
||||
|
||||
player = VideoPlayer(get_var("video_id"))
|
||||
|
||||
while(true)
|
||||
msg = wait(0, m.port)
|
||||
msgType = type(msg)
|
||||
|
@ -25,3 +23,8 @@ sub Main()
|
|||
end while
|
||||
end sub
|
||||
|
||||
|
||||
function get_var(key as String)
|
||||
return GetGlobalAA().Lookup(key)
|
||||
end function
|
||||
|
||||
|
|
67
source/VideoPlayer.brs
Normal file
67
source/VideoPlayer.brs
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user