Skip to main content

Chain play / Up Next

What you learn​

You're instantiating DIVA Player in your app and relying on DIVA Back Office as the video streaming source.

The goal of this article is to build the simplest front-end to stream a video from the DIVA Back Office with, at the end, the activation of Chain play / Up Next in combination with End of Play.

Before starting​

Instantiation​

Write the Basic instantiation code. There's no additional code to write, unless you need to overwrite the countdownToAutoplay or timeToDisableAutoplay property that the VideoMetadata/Endofplay contains.

Up next configuration​

Write the App() function to read the VideoMetadataMap as in the following example

Set the upNext property:

  • null default value if not set and up next not shown
  • This is the only mandatory value to set to show up next:
"upNext":{
"itemId":"<videoId>",
}
  • These are the complete fields that can be set:
"upNext":{
"itemId":"<videoId>",
"title":"<title>",
"caption":"<caption>",
"imageUrl":"<imageUrl>"
}

Autoplay configuration​

Set the countdownToAutoplay property:

  • 10000 default value if not set
  • 0 to set no autoplay
  • A positive integer that specifies the number of milliseconds before UpNext start automatically(Without user interaction). (eg: with 10000 the UpNext video starts automatically after 10 seconds).
"behaviour": {
"endOfPlay": {
"countdownToAutoplay":10000 //milliseconds, default 10000, 0 or negative means disabled
},
}

Set the timeToDisableAutoplay property in the settings file:

  • 5400000 default value if not set

  • A positive integer that specifies the number of milliseconds of user interaction before Autoplay to be disabled. (eg: with 5400000 the Autoplay is disabled after 90 minutes of user not interactions.

"general": {
"timeToDisableAutoplay": 5400000, //milliseconds, default 5400000
},

Working sample code for overwriting Chain play / Up Next data​

  • timeToDisableAutoplay Can not be overwriting on App side, it can be set only in the settings file(If is not set default value is applied).
  • countdownToAutoplay Can be overwriting on App side in the following way:
  • upNext Can be overwriting on App side in the following way:
private fun videoMetadataMapper(videoMetadata: VideoMetadata): VideoMetadata {
val endOfPlay = videoMetadata.behaviour?.endOfPlay?.copy(countdownToAutoplay = BigDecimal(20000))
val upNext = UpNext(itemId = videoId, title = title, caption = caption, imgUrl = imgUrl)

return videoMetadata.copy(
behaviour = videoMetadata.behaviour?.copy(endOfPlay = endOfPlay)
upNext = upNext
)
}

Behaviour​

  • Up Next will be shown only when the Squeeze Back feature is triggered or at the end of playback (if Squeeze Back is not enabled).
  • Up Next elements will be shown on the bottom left, including Next Episode Information and countdown to autoplay.
  • When casting to Chromecast, ChainPlay is disabled on the receiver device, meaning the next episode prompt and countdown will not be shown on the receiver.

Countdown Activation​

  • The countdown timer will display the remaining seconds as per the design specifications. If no countdown value is set, the timer will not appear.
  • When the countdown finishes, the next episode will automatically start unless the user interacts with the Endboard.

Countdown Cancellation​

  • If the user interacts with the Endboard, the countdown timer is canceled, and the automatic transition to the next episode is halted. The specific interactions that cancel the countdown vary by platform:
    • AndroidTV: Any focus change on the interface.
    • Mobile: Any interaction outside the "Next Episode" tile will stop the countdown.

Countdown to Up-Next​

  • When the countdown finishes without user interaction, the next episode will automatically load using the supplied video ID and begin playback.
  • When the user selects the "Next Episode" item by clicking or tapping on it, the next episode will launch immediately, overriding the countdown.

Autoplay Limitations​

  • To prevent continuous autoplay during inactive sessions, a ChainPlay timeout will be applied:
    • A session-based timer will track user inactivity. If the user does not interact with the device for a specified period, autoplay will be paused.
    • Any user interaction with the device (e.g., pressing buttons, moving the cursor, or tapping on the screen) will reset the inactivity timer, allowing autoplay to continue.

Dictionary​

Ensure the dictionary file contains the relevant keys.

  • diva_eop_upnext_title Is the translation key which is used for title of Up Next row, and should be set in the App dictionary file:

Analytics events​

Find here the available analytics events for the Chain play / Up Next.