Forum Discussion

jbrave's avatar
jbrave
Channel Surfer
16 years ago

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

5 Replies

  • Did you call SetMessagePort(port) on the screen you're currently displaying? If not, you won't capture any messages for it.
  • jbrave's avatar
    jbrave
    Channel Surfer
    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
  • jbrave's avatar
    jbrave
    Channel Surfer
    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
  • "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).
  • 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