Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
ashishtr
Level 7

Help required for ECP Command 'input'

Hi All,

I'm coding a roku app which will play videos and it's remote is written on android, from where you can control the videos to play.

I'm able to run it using ECP command 'launch' to open the app & play the desired url. but it reopens the every time. It is working As Expected, but I don't want it to reload.

So I tried to use the ECP command 'input', it opens & plays for the first time, but later it doesn't do anything when the app is running.

Do I need to do some special handling in my Roku app to handle 'input' command?

Thanks in advance for all the comments/suggestions and inputs.

----
Ashish
0 Kudos
6 Replies
Roku Employee
Roku Employee

Re: Help required for ECP Command 'input'

"ashishtr" wrote:
...
So I tried to use the ECP command 'input', it opens & plays for the first time, but later it doesn't do anything when the app is running.

Do I need to do some special handling in my Roku app to handle 'input' command?


It is admittedly cryptic, but this is described in the documentation:
https://sdkdocs.roku.com/display/sdkdoc ... ontrol+API

"The external control server places these name-value pairs into an associative array, and passes them directly through to the currently executing channel script using a Message Port attached to a created roInput object."
...
"Messages of type roInputEvent have a GetInfo() method that will obtain the associative array."

To paraphrase, your application needs to create a global roInput object, and set its message port to one that your application is always monitoring (whether it be in a main event loop or in a task event loop).

When the ECP input command for your app is processed by the firmware, if your app is already running it will be sent an roInputEvent event with the parameters in the event, equivalent to the main launch parameters.

It's then up to your app to handle roInputEvent appropriately, e.g. navigating to the target content springboard in the browse UI.
0 Kudos
ashishtr
Level 7

Re: Help required for ECP Command 'input'

Thanks for the reply, I'll look into this direction. Meanwhile is there any example or sample code to implement it.
0 Kudos
ashishtr
Level 7

Re: Help required for ECP Command 'input'

Finally I implemented it correctly by adding a roInputEvent. Now my code has started responding to the inputs. Thanks for the clue...

But now I got another problem regarding video component.
As soon as I change the stream url of the running video component, it doesn't retrieves the stream & stucks in between.

Do I need to create a new scene/screen to fix this problem. 


Thanks in advance for solution to this problem. Thanks.
0 Kudos
Roku Employee
Roku Employee

Re: Help required for ECP Command 'input'

"ashishtr" wrote:
...

But now I got another problem regarding video component.
As soon as I change the stream url of the running video component, it doesn't retrieves the stream & stucks in between.

Do I need to create a new scene/screen to fix this problem. 


Thanks in advance for solution to this problem. Thanks.


I suggest you start a new thread for this question, since it's not related to the ECP command.

Also, you will probably need to add more information about the problem to get any useful advice.
0 Kudos
jcb871
Level 7

Re: Help required for ECP Command 'input'

Just a bit of sample code to get inputs in a Roku channel. Hope this could help somebody without much effort.
Note this has to be in the main.brs after screen is shown.

  screen.show()
 
  m.msgPort = CreateObject("roMessagePort")

  while true
    'Create roInput in each loop so that every roInputEvent would be received
    m.input = CreateObject("roInput")
    m.input.SetMessagePort(m.msgPort)

    print "Waiting for input..."
    msg = wait(0, m.msgPort)
    if type(msg) = "roInputEvent"
      if msg.isInput()
        m.input = msg.GetInfo()
        print "Received input: "; FormatJSON(m.input)
      end if
    end if
  end while
end sub

Stored input into m.global and used below code in scene.brs to subscribe to the changes Smiley Happy

m.global.observeField("input", "onInputReceived")


function onInputReceived() as void
  print "Scene.onInputReceived"
end function
0 Kudos
Roku Employee
Roku Employee

Re: Help required for ECP Command 'input'

"jcb871" wrote:
...
  while true
    'Create roInput in each loop so that every roInputEvent would be received
    m.input = CreateObject("roInput")
    m.input.SetMessagePort(m.msgPort)
...


Note that you can and should move the creation and set up of m.input before the loop.
You only need/want a single roInput object for the whole application lifetime.
It isn't a one-shot use object, but rather will continue to receive all incoming events.
Hope that helps!
0 Kudos