Thread: Radio NPC help
View Single Post
  #4  
Old 05-01-2008, 12:42 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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 (lineobj.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); 

Reply With Quote