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.

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

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.

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.

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

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.