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

Stream Metadata

Hi guys,

I'm very new to development of any kind, so hopefully you guys can help.
I've looked a few other topics on this, but wasn't able to find any definite answers.

I'm setting up an audio streaming app for an internet radio station using the example from the SDK.
I'm wanting to take the metadata output from my shoutcast feed and input that into the artist and title section in the Roku channel. I'm assuming the metadata can be grabbed from the SONGTITLE area here - http://roca.abovecast.com:8014/statistics

How do I parse that and insert it into the channel, and have only the metadata refresh every 30 seconds or so?

Here's what I've got so far. Mostly just pulled from the example in the SDK.

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


Any help would be appreciated.
0 Kudos
3 REPLIES 3
belltown
Roku Guru

Re: Stream Metadata

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.
0 Kudos
CamBlack
Visitor

Re: Stream Metadata

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


The stream was actually already working with the code I provided. Sorry, should have been clear about that.

The only thing I'm really stuck on is the meta data. I've found this on the forums: viewtopic.php?f=34&t=66909&p=428066#p428064
I'm guessing I could use that same code, but I'm not entirely sure how to insert that information into where the Artist and Title should be in the original code.
It also looks to be like the artist and title need to be split up and inserted separately. Hopefully this make sense.

I'm generally not one to ask for help, but after hours of digging through this forum and looking at a number of threads, I'm still clueless.
Getting the stream to play was easy. The metadata, not so much.

I'd also love to figure out a way to pull album art if that's possible, but I'll save that for another day.
0 Kudos
belltown
Roku Guru

Re: Stream Metadata

I see what you mean. Yes, you'll have to split the SONGTITLE field into artist and song. Something like this:


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
0 Kudos