Roku SDK
This guide explains how to integrate DIVA into your Roku channel application.
Requirements​
The SDK self-contains every dependency you need for DIVA Player integration and run:
components/divaPlayer
folder contains all DIVA Player related source codesresources/fonts
folder contains font files for DIVA Player UIresources/images
folder contains all graphic assets for DIVA Player UI
SDK Setup​
Unzip Roku SDK package and copy components
and resources
folders into the root of your Roku channel application project
Initialization​
Follow steps described below for correct DIVA Player initialization and run:
- Add
divaPlayerUtils.brs
file into your main scene file as source file
<?xml version="1.0" encoding="UTF-8"?>
<component name="MainScene" extends="Scene">
<script type="text/brightscript" uri="pkg:/components/MainScene.brs"/>
<script type="text/brightscript" uri="pkg:/components/divaPlayer/divaPlayerUtils.brs"/>
<interface>
</interface>
<children>
<Group id="screensStack"/>
</children>
</component>
- Get DIVA Player component instance with
getDivaPlayer()
function, add it to scene components stack and set focus insideinit
method of your main scene
divaPlayer = getDivaPlayer()
screensStack.appendChild(divaPlayer)
divaPlayer.setFocus(true)
- Set launch parameters to DIVA Player with
setDivaPlayerLaunchParams(arg)
function with argument of object type
setDivaPlayerLaunchParams({
videoId: ["id"]
deepLinkValue: value
deepLinkType: "type"
preferredCCTrackName: "track"
preferredAudioTrackName: "track"
hdrMode: true
' accessibility options
darkerBackgroundCc: true
enlargedCc: false
opaqueBackground: false
ccEnhancementsOptionEnabled: false
transparencyOptionEnabled: false
...
})
- Set dictionary to DIVA Player with
setDivaDictionary(arg)
function with argument of object type
setDivaDictionary({
messages : {
key1: value1,
key2: value2,
...
}
})
- Set settings to DIVA Player with
setDivaSettings(arg)
function with argument of ContentNode type
settings = CreateObject("roSGNode", "ContentNode")
settings.addFields({
key1: value1
key2: value2
...
})
setDivaSettings(settings)
- Observe required get metadata call from DIVA Player with function
observeDivaMetadataUpdate
and serve metadata in handler with functionsetDivaMetaData(arg)
. An argument type forsetDivaMetaData
function should be ContentNode
observeDivaMetadataUpdate("onMetadataUpdateHandler")
...
sub onMetadataUpdateHandler()
metadata = CreateObject("roSGNode", "ContentNode")
metadata.addFields({
title: "Title"
sources: [
{
uri: "uri value",
format: "format value",
},
],
...
})
setDivaMetaData(metadata)
end sub
- Observe other callbacks from DIVA Player if needed
' Observe DIVA Player exit call
observeDivaPlayerExit("onDivaPlayerExitHandler")
' Observe DIVA Player Error call
observeDivaPlayerError("onDivaPlayerError")
' Observe DIVA Player selected Audio track call
observeDivaPlayerSelectedAudioTrack("onSelectedAudioTrackHandler")
' Observe DIVA Player selected Closed Captions track call
observeDivaPlayerSelectedCC("onSelectedCCTrackHandler")
' Observe DIVA Player generic analytics event call
observeDivaPlayerAnalyticsEvent("onAnalyticsEventHandler")
' Observe DIVA Player media analytics event call
observeDivaPlayerMediaAnalyticsEvent("onMediaAnalyticsEventHandler")
...
sub onDivaPlayerExitHandler()
' Exit from DIVA Player
end sub
sub onDivaPlayerError(evt)
' DIVA player error
end sub
sub onSelectedCCTrackHandler(evt)
' Selected closed captions track
end sub
sub onSelectedAudioTrackHandler(evt)
' Selected audio track
end sub
sub onAnalyticsEventHandler(evt)
' Generic analytics event handler callback
end sub
sub onMediaAnalyticsEventHandler(evt)
' Media analytics event handler callback
end sub
- Run DIVA Player with
runDivaPlayer()
function
runDivaPlayer()
DIVA Player will run in full screen mode as a result.