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

Need To Display Artist and Title for Live Radio Stream

I have been scouring these threads for the past few days to no avail. I found a couple of references to this, but I did not seem to find any published resolutions. I am trying to build a channel for a live Internet radio station. I have a developer account, and I have the latest SDK. So far I've been successful in being able to get the live audio stream to work. I was able to do it using both the NPR example in the SDK as well as the basic video player (sans video of course).
However, what I can't seem to accomplish is how to display the Artist and Title now playing information on the screen. Firstly, I will say that from what I've read and been told, I am aware that the Roku cannot strip the metadata contained within the mp3 audio stream. That's fine because the live automation software which powers the radio station makes this data available via other means. i.e. it can upload an HTML file with the data, it can upload an XML file with the data, etc. And, this file is re-uploaded with new data upon each song change.
So, while I'm not trying to parse metadata from within a live mp3 audio stream, I am hoping to find a way to parse/poll said HTML or XML file and display this data on screen. I will also need this method to be able to refresh either at a set interval or some other way so that the Now Playing information being displayed is always current.
For what it's worth, the ShoutCast channel does this. Somehow they strip out the mp3 stream metadata and seemingly convert it to XML on their server - and then their Roku channel parses this data and displays it both on the player page and then on the screensaver once the screensaver kicks in. And they do display it in real time - updating it after a song change.
Does anyone have any insight as to how I can accomplish this?
Again, it all seems to boil down to a simple parsing of a basic file that sits on a remote server and to have this parsing refreshed every 30 seconds or so. Any help will be greatly appreciated.
0 Kudos
5 REPLIES 5
RokuJoel
Binge Watcher

Re: Need To Display Artist and Title for Live Radio Stream

Most shoutcast servers have a few places where you can get the song data.

http://server.com:port/7.html will give you the name of the song, you will need to strip out the info there that isn't relevant, and be aware it isn't always the same from one song to the next, you will also have to handle weird characters in song titles like umlauts without crashing your channel.

http://server.com:port/played.html will give you a list of recently played songs usually but not always including the currently playing song (I believe 7.html is the most accurate for what is actually being played on the server). Due to the possibility that there may be a large amount of buffered data on the device, it is possible that the server has already moved on to the next song but the Roku is still playing the last song.

In both these cases you will need to use a few different tools to parse the data, for example the tokenize(",") will convert 7.html to an array. For played.html you will either figure out a way using regex if you are a regex jockey, or you will use left() right() mid() and instr() and also will probably need a replaceSubstring function. There also should be some html tag stripping functions of use in urlUtils.brs and generalUtlis.brs floating around in the Roku SDK.


- Joel
0 Kudos
marsradio
Visitor

Re: Need To Display Artist and Title for Live Radio Stream

Thank you, Joel, for responding to this so quickly. Since reading your response, I've been scouring this forum and searching elsewhere to try to find more information that could help me with this, but I've had no luck.

I did know about the/played.html feature on the ShoutCast server. However, I did not know about the /7.html feature. The data given at /7.html seems simple enough. Unfortunately, I have absolutely no experience in how to pull this data into the Roku player. I have no experience with Brightscript. For what it's worth, I've been doing HTML for 17 years, PHP and Perl for about 15 years, and CSS for about 8 years. I'm not a noob by any means, but I just don't really know how to make heads or tails with Brightscript. And, it seems that for this particular need - having Artist and Title display in real time on a live radio stream - there isn't going to be much information out there.

So, I guess my next question is: Is there anyone on here who is willing to offer their services for hire or who could point me to a working example of how to do this.

Again, I can either go the route of parsing the /7.html data from ShoutCast, or I can create an XML file that is regularly updated by the automation server.

With ShoutCast's app/channel on Roku, I don't think they are parsing the /7.html file to display Artist / Title data. They must be parsing their database somehow or parsing a file pulled from their database or their "YP" as they call it.

If anyone can help me get this going I would be very appreciative. And, if it is for hire, then we can discuss those terms via PM. Otherwise, I don't see how I can move forward with this project since a radio station app is quite useless without Artist and Title information. Thank you in advance to anyone who can help me.
0 Kudos
sjssoft
Visitor

Re: Need To Display Artist and Title for Live Radio Stream

I have successfully done this:

Following is the php code:

<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://127.0.0.1:8000/7.html"); // Replace your IP with 127.0.0.1 and port number with 8000
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
$shoutcast = curl_exec($curl);
preg_match("/<body.*>(.*)<\/body>/smU",$shoutcast, $match);
echo $match[1];
?>


If you need my help, Please visit me @ http://sjssoft.com
😄 😄 😄 😄
0 Kudos

Re: Need To Display Artist and Title for Live Radio Stream

I am currently building a Radio Station website on Wordpress and have been searching all day for a Now Playing script.
I am a bit of a rookie when it comes to php coding - could you let me know if I can use this in Wordpress and where I'd add it please?
I'm trying to add it to my header.

Thanks so much in advance

Hayley
0 Kudos
sjssoft
Visitor

Re: Need To Display Artist and Title for Live Radio Stream

Yes, you can use it in wordpress also. Just make a new page shoutcastPage.php and save the above code in it. Then include it any where you want to call it. For more details, please come to gmail on video chat at sjssoft87@gmail.com
0 Kudos