3

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.

garfbradaz
  • 3,424
  • 7
  • 43
  • 70
Anon Mouse
  • 31
  • 2

4 Answers4

1

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

Abhishek
  • 3,304
  • 4
  • 30
  • 44
  • suggest adding a code example of this, rather than the link to docs. – Jess Bowers Jan 26 '18 at 15:18
  • I have added the video player example link in my answer. In that code also you need to add the Live Field change as I have mentioned in my answer. – Abhishek Jan 29 '18 at 05:23
  • go ahead and copy/paste the code into your answer, with the updates you describe. SO prefers inline code to links, because the links can grow stale. – Jess Bowers Jan 29 '18 at 15:35
  • Code doesn’t have the single file. Also it’s a very simple thing which roku has proper documentation and samples since day one. The important point was the flag what I have already mentioned. Even code recommendation and asking for samples is against the stack overflow policy. You can get those options when you raise a flag for any question. – Abhishek Jan 29 '18 at 15:40
  • Even if i add the live content to true, trick play buttons are still functioning. anyone was able to resolve this? – nithin ks Mar 08 '18 at 05:55
1

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"

0

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

0

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
Phat Le
  • 3
  • 1
  • 5