Home:ALL Converter>Setting caption styles on Roku Scene Graph Video node via code in channel application

Setting caption styles on Roku Scene Graph Video node via code in channel application

Ask Time:2018-06-08T22:02:14         Author:Esteban

Json Formatter

I am developing a Roku channel app. I am having trouble applying styles to the subtitles for a Scene Graph Video node.

If I set caption styles globally via the system's Settings screen, the subtitles do appear stylized over my full-screen, focused Scene Graph Video node (background color, text color, text edge effect, they all work as expected.) However, I cannot replicate this via code on my channel app.

I understand that Scene Graph Video node's captionStyle property is only available since firmware version 8.0. My Roku Device has such exact version, and so does a second, much newer, Roku device I have tested this on.

Here is my BrightScript code (I have added a firmware version check just to be able to tell if the positive branch of the if statement does execute):

m.video.globalCaptionMode = "On"
m.video.subtitleTrack = params.subtitlesUrl

print "Caption Style before our customizations: "; FormatJson(m.video.captionStyle) ' Prints null

firmwareVersion = GetFirmwareVersion()

if firmwareVersion >= 8 then

    captionStyle = {
        "Background Color": "Yellow"

    m.video.captionStyle = captionStyle

    print "Subtitles Style set on Video node: "; FormatJson(m.video.captionStyle) ' Prints the assoc array as expected

    print "Caption Style not supported on firmware version: "; firmwareVersion
end if

Please note that the first print statement that includes m.video.captionStyle, before applying my customizations, prints null. I would expect it to display the current global system settings, at least (if the property is intended for reading and not just writing, as some properties are.) My guess is that the captionStyle property does not belong to the Video node directly, yet I am unable to find any examples on the official Roku SDK documentation or elsewhere (this site included.)

A second guess is that perhaps the keys on the captionStyle associative array should not be specified as a string value (this associative array literal style is also new, but the BrightScript Eclipse plug-in does not complain, nor does the Roku itself during actual execution.) That is, instead of:

captionStyle = {
    "Background Color": "Yellow"

The entry may have to set as this:

captionStyle = {
    backgroundColor: "Yellow"

But it does not work either. By reading the Roku SDK documentation for the captionStyle property (https://sdkdocs.roku.com/display/sdkdoc/Video) I would expect it to be specified as a string (including spaces), in fact.

Any ideas? Thanks.

Author:Esteban,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762386/setting-caption-styles-on-roku-scene-graph-video-node-via-code-in-channel-applic