Skip to main content

Importing the Lura Player

The Lura Player is a powerful component for integrating video playback capabilities into your Roku applications. This guide will walk you through the process of importing and using the Lura Player in your Roku Player SDK project.

Basic import

Add LuraPlayer ComponentLibrary into your component between the <children> tags.

    <ComponentLibrary id="lib" uri="https://w4.mp.lura.live/p/[YOUR_PLAYER_ID]/LuraPlayer.pkg" />

Example usage

MainScene.xml
<?xml version="1.0" encoding="utf-8"?>
<component name="MainScene" extends="Scene">
<children>
<ComponentLibrary id="lib" uri="https://w4.mp.lura.live/p/[YOUR_PLAYER_ID]/LuraPlayer.pkg" />
</children>
<script type="text/brightscript" uri="MainScene.brs" />
</component>
MainScene.brs
sub init()
m.lib = m.top.findNode("lib")
m.lib.observeField("loadStatus", "onLoadStatusChanged")
end sub

sub onLoadStatusChanged()
if m.lib.loadStatus <> "ready"
return
end if
m.player = CreateObject("roSGNode", "Lura:LuraPlayer")
m.top.appendChild(m.player)
m.player.callFunc("setConfig", {
"content": {
"media": [
{
"url": "https://example.com/master.m3u8",
"type": "application/x-mpegURL",
"licenseUrl": "..."
}
]
}
})
m.player.callFunc("play")
m.player.setFocus(true)
end sub

With LoadingScene

Create a LoadingScene for loading the ComponentLibrary

LoadingScene.xml
    <ComponentLibrary id="lib" uri="https://w4.mp.lura.live/p/[YOUR_PLAYER_ID]/LuraPlayer.pkg" />

Insert a LuraPlayer node into your MainScene

MainScene.xml
    <Lura:LuraPlayer id="player" />

Example usage with LoadingScene

LoadingScene.xml
<?xml version="1.0" encoding="utf-8"?>
<component name="LoadingScene" extends="Scene">
<interface>
<field id="loaded" type="boolean" />
</interface>

<children>
<ComponentLibrary id="lib" uri="https://w4.mp.lura.live/p/[YOUR_PLAYER_ID]/LuraPlayer.pkg" />
</children>
<script type="text/brightscript" uri="LoadingScene.brs" />
</component>
LoadingScene.brs
sub init()
m.lib = m.top.findNode("lib")
m.top.loaded = false
m.lib.observeField("loadStatus", "onLoadStatusChanged")
end sub

sub onLoadStatusChanged(msg)
status = msg.getData()
if status = "ready"
m.top.loaded = true
end if
end sub
MainScene.xml
<?xml version="1.0" encoding="utf-8"?>
<component name="MainScene" extends="Scene" initialFocus="player">
<interface>
<field id="exit" type="boolean" value="false" />
</interface>

<script type="text/brightscript" uri="MainScene.brs" />

<children>
<Group>
<Lura:LuraPlayer id="player" />
</Group>
</children>
</component>
MainScene.brs
sub init()
m.player = m.top.findNode("player")
m.player.callFunc("setConfig", {
' ... your config
})
m.player.control = "play"
end sub
Main.brs
sub Main(input as dynamic)
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("LoadingScene")
screen.show()
scene.observeField("loaded", m.port)
while true
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
if msgType = "roSGNodeEvent"
field = msg.getField()
data = msg.getData()

if field = "loaded" and data = true
exit while
end if
end if
end while
showHeroScreen(input)
end sub

sub showHeroScreen(input as object)
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("FeedScene")
screen.show()

scene.observeField("exit", m.port)
while not scene.exit
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end while
end sub