Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jbrave
Channel Surfer

waiting for messages

Now that I've learned how to retrieve xml and parse it for url's to play, how to enque the urls into an roAudioPlayer, and start it playing, I'm trying to learn how to do button detection so I can pause, skip, exit, etc. I've slightly modified this code snippet from the RokuDVP Component Reference to print out messages, but all it prints are the messages coming from the roAudioPlayer, not button presses on the remote. What am I missing?


while true
msg = wait(0, port)
?type(msg)
?"message is: ";msg.getmessage()
if type(msg) = "roAudioPlayerEvent"
if msg.isStatusMessage() then
print "roAudioPlayerEvent: "; msg.getmessage()
if msg.getmessage() = "end of playlist" return

endif
endif
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
5 REPLIES 5
TheEndless
Channel Surfer

Re: waiting for messages

Did you call SetMessagePort(port) on the screen you're currently displaying? If not, you won't capture any messages for it.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jbrave
Channel Surfer

Re: waiting for messages

I'm not displaying a screen, everything is just back-end: get xml, parse, load list of url's into player, and call audioplayer.play

Do I need to have a screen up to listen for button press messages? I figured I would learn the back end and build the "meat" of my app before tackling the visual side of it...

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
jbrave
Channel Surfer

Re: waiting for messages

Thanks for responding - Ah I see, I need to tell some component (presumably one that handles the remote buttons) to send messages to the port I'm using, not just the audio player. So I have audioplayer.setmessage(port) but I need to do that for whatever component I'm listening for.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: waiting for messages

"jbrave" wrote:
Thanks for responding - Ah I see, I need to tell some component (presumably one that handles the remote buttons) to send messages to the port I'm using, not just the audio player. So I have audioplayer.setmessage(port) but I need to do that for whatever component I'm listening for.

- Joel

Right. As far as I'm aware, only screens can receive button presses, so you'll need to display some screen to do what you're trying. Make sure you assign both the screen and the audioplayer the same port, otherwise you'll only receive messages for one of the other (depending on your Wait statement).
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
RokuKevin
Visitor

Re: waiting for messages

Yes, TheEndless is correct that you need to call SetMessagePort on a screen that propagate remote buttons. Some screens catch the buttons and process them internally (for example the roVideoScreen will pause the video when you click pause and not propagate the isRemoteKeyPressed() event to the message port.

--Kevin
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.