Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-30-2008, 09:58 PM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Radio NPC help

I've made a Radio NPC that streams songs off the internet but how do I find the Artist and Title of the current song? I've seen server Aeon done this, so I know this is possible.
Reply With Quote
  #2  
Old 04-30-2008, 10:12 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Yeah, I always wondered where that info came from my self. I'm assuming your streaming from a pls file or so, right?
__________________
Do it with a DON!
Reply With Quote
  #3  
Old 05-01-2008, 12:38 AM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by zokemon View Post
Yeah, I always wondered where that info came from my self. I'm assuming your streaming from a pls file or so, right?
Although you cannot get the current title name off of a stream in particular, you can get the name off of the ID3 tags (if provided with the files) by using getmusictags(). This returns a list of the ID3 tags of the file in an array.
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #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
  #5  
Old 05-01-2008, 03:42 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
thanks for the script Skyld but it only shows Stream - ?
Reply With Quote
  #6  
Old 05-01-2008, 05:01 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stryke View Post
thanks for the script Skyld but it only shows Stream - ?
It's possible the stream you're using doesn't give ID3 data ... did you try a different stream?
__________________
Reply With Quote
  #7  
Old 05-01-2008, 05:30 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Awesome, thanks Skyld!

I tried it with http://208.122.59.30:7274 (Tribal House stream on di.fm) and got the following:
NPC Code:
music data: ARTIST - Alejandro Rado
music data: TITLE - Push The Desert (March 2008 pt1)
music data: StreamUrl -

__________________
Do it with a DON!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:03 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.