Search code examples
rokubrightscript

How to Set Text above in Video on Roku


I tried to Display text on Video. I press into pause key then display text above on video again I press the same key then remove display text It's possible in Roku.


Solution

  • First add Your label as a child of Your Screen/View/Scene where You also added Video Node but make sure to add it after Your Video Node in order to render the Label on top of it. So for example, in You Screen/View/Scene, Video Node should be child with the index 0 and Label should be child with index 1. In Screen/View/Scene .xml add:

    <Label
      id="testLabel"
      height="44"
      width="0"
      font="font:MediumBoldSystemFont"
      text = "Application Development Made Easy!"
      horizAlign = "left"
      vertAlign = "center"
      translation="[318,8]" />
    

    In Screen/View/Scene .brs add: m.testLabel = m.top.findNode("testLabel") Then add a onKey function to Screen/View/Scene .brs:

    function onKeyEvent(key as String, press as Boolean) as Boolean
    
      handled = false
      if press = true and key = "play"
          if videoNode.state = "playing"
            m.testLabel.visible = true
          else if videoNode.state = "paused"
            m.testLabel.visible = false
          end if
          handled = true
      end if
    
      return handled
    end function