Your Digital Media Has Never Looked So Good

 
kressaty
Topic Author
Posts: 3
Joined: Thu May 20, 2010 10:03 pm

roAudioPlayer Usage and Help

Wed May 26, 2010 11:39 pm

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!
 
renojim
** Valued Community Member **
Posts: 3491
Joined: Mon Feb 15, 2010 1:35 pm

Re: roAudioPlayer Usage and Help

Thu May 27, 2010 3:42 pm

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"
songs.Push(song)

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"
songs.Push(song)

audio = CreateObject("roAudioPlayer")
audio.SetContentList(songs)


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.
-JT

Who is online

Users browsing this forum: No registered users and 3 guests