Roku Developer Program

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

roAudioPlayer Usage and Help

I'm building an audio player for use with a mid-sized (600,000+ tracks) music service that allows playback of albums, songs, playlists, etc. It's all fed from XML requests, and data is fairly easy to manipulate into whatever I need for BrightScript.

That being said, I'm getting frustrated with the roAudioPlayer and its usage, as well as interaction with roSpringboardScreen.

The audio player example source code makes it seem like you should just be able to pass in a list of URLs to playback, but I can't get this to work. I'm also confused as to how you can update the information on the screen (artist, album, title, etc.) when the next item plays - I feel like this information could be updated using the isStatusMessage = "end of stream" option, but the documentation and example mark this as deprecated and yet do not really suggest an alternative. Does anyone have any suggestions?

My goal is to be able to pass my Audio player an array of tracks with [artist, album, title, url, format] (and more information in the future) for each track in my list, specify the index of which track to start on (say the user chooses track 5 instead of track 1) and have the roAudioPlayer play the subsequent tracks and then be able to repeat to the beginning. Any code or examples would be much appreciated.

I know this is somewhat whiny and specific, but it seems that the majority of posts on the forum have to do with video issues and hobbyists trying to build their own UPnP streaming apps - audio and its support on the device seem somewhat of an afterthought. I'd love to see the ability to have larger album art and more information on screen, which I'm hoping will be possible with the new custom screens in the new SDK.

I apologize I can't get into the fine details of the service provider. Any input would be much appreciated!
0 Kudos
1 Reply
Level 17

Re: roAudioPlayer Usage and Help

You need to pass the roAudioPlayer an array of roAssociativeArray's. Your code should look something like this simplified example:
songs = CreateObject("roArray")
song = CreateObject("roAssociativeArray")
song.url = "http://ip/song1.mp3"
song.length = 300 ' 5 minutes
song.artist = "artist 1"
song.title = "title 1"
song.album = "album 1"

song = CreateObject("roAssociativeArray")
song.url = "http://ip/song2.mp3"
song.length = 240 ' 4 minutes
song.artist = "artist 2"
song.title = "title 2"
song.album = "album 2"

audio = CreateObject("roAudioPlayer")

I'm sure someone from Roku will correct me if I'm wrong, but I believe the isRequestSucceeded() event is the same as the "end of stream". You could use that or the isListItemSelected() event to set the content of the SpringBoard screen. You'll get an isFullResult() event from the audio player when all songs have played - after song2.mp3 in my simple example.

Hope this helps.
0 Kudos