Function CreateNPRSongList() as Object
aa = CreateObject("roAssociativeArray")
aa.posteritems = CreateObject("roArray", 10, true)
song = CreateSong("Jammin 101","Title","Artist", "mp3", "http://roca.abovecast.com:8014","http://puu.sh/b4QcL/ed83a0a2bd.jpg")
aa.posteritems.push(song)
return aa
End Function
"belltown" wrote:
It's definitely possible. The station broadcasts an MP3 stream, which the Roku will handle, although you'll need to make sure you specify the correct stream url: http://roca.abovecast.com:8014/stream
And yes, you should be able to extract the song title and artist from the metadata url you specified. You can use the roUrlTransfer component to read the metadata url then parse the Xml using roXmlElement. You'll use roAudioPlayer to play the mp3 stream. If you follow the model from the Roku examples, you can use an roSpringboardScreen as the UI component on display while the audio is playing. In the main processing loop you'll handle roAudioPlayerEvent and roSpringboardScreenEvent events. To handle refreshing the displayed metadata every 30 seconds or so, you can use an roTimespan and check the elapsed time each time through your wait loop. After 30 seconds send off an roUrlTransfer AsyncGetToStringRequest; handle the roUrlEvent in your main wait loop, which you can use to get the xml data when the event completes.
I'd suggest taking it in small steps. First, get the audio stream working by itself without the metadata, by just changing the url in the audioplayer SDK example. Then try reading the xml url before you set up the initial screen content, e.g. in CreateNPRSongList. You can use my readXml function here: http://forums.roku.com/viewtopic.php?f=34&t=72657#p451837 to read and parse the metadata Xml. Later on you can add the code to update it every 30 seconds.
xml = readXml ("http://roca.abovecast.com:8014/statistics", 5000)
if xml <> Invalid
artistAndSong = xml.STREAM.SONGTITLE.GetText ()
matchArray = CreateObject ("roRegex", "(.*?) - (.*)", "").Match (artistAndSong)
if matchArray.Count () > 1 then artist = matchArray [1] else artist = "Unknown artist"
if matchArray.Count () > 2 then song = matchArray [2] else song = "Unknown song"
endif