Chain play / Up Next
What you learn​
You are instantiating DIVA Player in your Roku application and relying on DIVA Back Office as the video streaming source.
The goal of this article is to build the simplest Roku application to stream a video from the DIVA Back Office with, at the end, the activation of up-next in combination with end of play.
Before starting​
- Ensure
Diva Player lib
andDIVA Back Office Adapter lib
downloaded (Setup > Step 13). - Ask your video engineers team the
<video id>
and the related<settings URL>
. - Ensure the VideoMetadata contains the upNext property.
- Ensure the VideoMetadata contains the countdownToAutoplay property.
- Ensure the settings contains the timeToDisableAutoplay property.
Instantiation​
Write the Basic instantiation code. There's no additional code to write, unless you need to overwrite the autoplay behavior that the VideoMetadata contains.
Up next configuration​
Write the observer on the field m.boAdapterNode.videoDataNode
to get the VideoMetadataMap as in the folllowing example, and set the upNext
property:
undefined
default value if not set and up next not shown- This is the only mandatory value to set to show up next:
{
...
upNext: {
{ videoId: "<videoId>" }
}
}
- These are the complete fields that can be set:
{
...
upNext: {
videoId: "<videoId>",
title: "<title>",
caption: "<caption>",
imageUrl: "<imageUrl>",
}
}
Autoplay​
Write the observer on the field m.boAdapterNode.videoDataNode
to get the VideoMetadataMap as in the following example, and set the endOfPlay
property:
{
...
"behaviour": {
"endOfPlay": {
"countdownToAutoplay":10000 'milliseconds, default 10000, 0 or negative means disabled
},
},
}
In the settings
file, the general
section must contain "timeToDisableAutoplay": 5400000
, like in the following example:
{
...
"general": {
"timeToDisableAutoplay": 5400000, 'milliseconds, default 0, 0 or negative means disabled
},
}
The autoplay will start if countdownToAutoplay
has set. In this case the countdown will start.
countdownToAutoplay
will enable or disable the autoplay at the end of the milliseconds set ()
Working sample code (.brs)​
sub launchBOAdapter(divaLaunchParams as object)
...
' Observe BO Adapter VideoMetaDataNode
m.boAdapterNode.observeField("videoDataNode", "onBOAdapterVideoDataNodeHandler")
...
end sub
sub onBOAdapterVideoDataNodeHandler(evt as dynamic)
data = evt.getData()
data.addFields({
upNext: {
itemId: "next video id <videoId>",
title: "Video Title",
caption: "Sub Title",
imageUrl: "https://www.example.com/image.jpg",
}
behaviour: {
endOfPlay: {
countdownToAutoplay: 10000 'milliseconds, default 10000, 0 or negative means disabled
},
}
})
' Setup Diva Player Metadata
m.dpUtilsNode.callFunc("setMetaData", data)
end sub
sub onSettingsHandler(evt as dynamic)
data = evt.getData()
if data.general = invalid
data.addFields({general:{}})
end if
general = data.general
general.AddReplace("timeToDisableAutoplay", 5400000) 'milliseconds, default 0, 0 or negative means disabled
data.general = general
' Setup Diva Player Settings
m.dpUtilsNode.callFunc("setSettings", data)
end sub
Dictionary​
Ensure the dictionary file contains the relevant keys.
Analytics events​
Find here the available analytics events for the Chain play / Up Next.