Stefan posted about this some time ago:
HTML Code:
- script functions getMusicTags() (returns array) and getMusicStatus()
(returns string) for knowing more about the currently
played music
- script event onMusicDataReceived(dataname,datavalue) for
getting the title and artist of an internet stream (the stream server
is sending this all few seconds)
PHP Code:
//#CLIENTSIDE
function onCreated() {
// Retrieve the playlist via http
this.req = requestURL("http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=3281&file=filename.pls");
catchevent(this.req,"onReceiveData","onData");
}
function onData(obj) {
// Got the playlist data:
// parse the returned data for a line like "File1=http://streamlocation"
for (line: obj.data) {
if (line.starts("File1=")) {
// Play the real url
play(line.substring(6));
// Also start a timer to display the music info
setTimer(0.1);
break;
}
}
this.req = NULL;
}
function onTimeout() {
// Display the music data
if (getMusicStatus()!="")
echo("music status: " @ getMusicStatus());
if (getMusicStatus()=="ok")
echo("music info: " @ getMusicTags());
else
setTimer(0.1);
}
function onMusicDataReceived(dataname,datavalue) {
// Music meta data is sent by the stream server
// all few seconds, dataname is either ARTIST or TITLE
echo("music data: " @ dataname @ " - " @ datavalue);
}