Anon Mouse
Anon Mouse

Reputation: 31

Disabling remote (trick play) buttons in a Roku live streaming application video node?

I'm having trouble disabling the remote control buttons like "fast forward", "pause", etc. in my Roku application. It is a very simple application that just has the one main scene, which only creates a video node that plays a live stream of our television channel. It was accepted by Roku accept that they require you to disable the trick play buttons like "fast forward" during a live stream. The documentation says this should be handled with the "onKeyEvent()" function. If the event is handled, it 'shouldn't' bubble up and be handled by the firmware. I can console log to prove that the function is firing but when I turn "handled" to true and return it, it seems to have no effect. all the buttons continue to fire and do their thing.

I have used their provided example and have even simplified it all the way down to just turning "handled" to true, unconditionally. (among other things) I have tried moving it from the video scene brs file to main (where everything is initialized) and moving it around but I am stumped. It fires when the buttons are pressed but returning true seems to do nothing.

The app only starts up, creates the video node and begins playing the stream. Other than firing a google analytics event, it does nothing else.

Roku's example: (https://sdkdocs.roku.com/display/sdkdoc/Handling+Application+Events#HandlingApplicationEvents-HandlingRemoteControlKeyPresses)

function onKeyEvent(key as String, press as Boolean) as Boolean
  handled = false
  if press then
    if (key = "back") then
      handled = false
    else
      if (m.warninglabel.visible = false)
        m.warninglabel.visible="true"
      else
        if (key = "OK") then
          m.warninglabel.visible="false"
        end if
      end if
      handled = true
    end if
  end if
  return handled
end function

Is there something am missing about this? If anyone knows how to disable these buttons, I would be more than grateful.

Upvotes: 3

Views: 1196

Answers (4)

Phat Le
Phat Le

Reputation: 3

You can setup a custom component which extends Roku Video component and override its onKeyEvent function as below

function onKeyEvent(key as String, press as Boolean) as Boolean
        if (press) 
           if (key = "replay" OR key = "fastforward" OR key = "rewind")
               return true
        end if
    end if
      return false
end function

Upvotes: 0

JSON Derulo
JSON Derulo

Reputation: 76

You can try setting the enableUI and enableTrickPlay fields on the video node. Also, if the video node has focus, it will automatically handle certain key presses. If it is not focused, it will not handle those key presses automatically. The key presses that are not handled will bubble up out of the video player and up the focus chain. What the focus chain is depends on your code. But it should look something like this from top to bottom.

main.brs MainScene All your other components

Upvotes: 0

Abhishek
Abhishek

Reputation: 3624

You don't need to do in onKeyEvent function as you have mentioned in your question.

Just set "Live" field value to true in content meta-data for video node, as mentioned in documentation https://sdkdocs.roku.com/display/sdkdoc/Content+Meta-Data

If will handle the video controls for your live content.

You can find the sample video player code in https://github.com/rokudev/simple-videoplayer-channel

Upvotes: 1

Keshav Goel
Keshav Goel

Reputation: 74

I wonder why did you not use "enableTrickPlay" and "enableUI" fields of the Video node for the purpose. Please check : https://sdkdocs.roku.com/display/sdkdoc/Video under "UI Fields"

Upvotes: 1

Related Questions