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: 
beowulf573
Visitor

roAudioPlayer and current item

Is there a way to detect the current item from the content list currently being played by a roAudioPlayer?

I'd like to set a list of items, start playing, navigate other screens, and ultimately come back to a "Now Playing" screen. But since I'll be moving about I may not get the list item change message from the audio player in order to update the current item.

Thanks.
0 Kudos
5 REPLIES 5
renojim
Community Streaming Expert

Re: roAudioPlayer and current item

I don't think so. If you use one message port for all your screens you can check for roAudioPlayerEvents in all your message loops and keep track of when a new list item is selected that way.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
jbrave
Channel Surfer

Re: roAudioPlayer and current item

Another approach which I use is to create a global roaudioplayer, which you can use with any port, and store now-playing info in global variables, and a single audio event handler which you can call from any function on an audioplayer event, so you can track the current state from anywhere.
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
beowulf573
Visitor

Re: roAudioPlayer and current item

Is there a downside to using the same port object on all screens? I already have a global player and associated port, so I could use reuse that port for the poster screens, etc, and route audio events to common code.

Thanks.
0 Kudos
renojim
Community Streaming Expert

Re: roAudioPlayer and current item

I think the downside would be if you opened two of the same type of screen, one on top of the other, you'd have to be sure you knew which screen the events were meant for. I don't think that's much, if any, of a downside and in fact the documentation for roSystemLog recommends using one roMessagePort throughout your application if you want to use that component.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
beowulf573
Visitor

Re: roAudioPlayer and current item

Great, thanks. I just refactored my code to use a single message port, but haven't had time to really test it. I'll keep an eye out for odd messages. I check in each screen event loop for an audio event and handle it, and also use a time span to update the current play time.
0 Kudos