Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Radio NPC help (https://forums.graalonline.com/forums/showthread.php?t=79579)

Stryke 04-30-2008 09:58 PM

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.

zokemon 04-30-2008 10:12 PM

Yeah, I always wondered where that info came from my self. I'm assuming your streaming from a pls file or so, right?

Programmer 05-01-2008 12:38 AM

Quote:

Originally Posted by zokemon (Post 1388349)
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.

Skyld 05-01-2008 12:42 AM

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); 



Stryke 05-01-2008 03:42 AM

thanks for the script Skyld but it only shows Stream - ?

cbk1994 05-01-2008 05:01 AM

Quote:

Originally Posted by Stryke (Post 1388448)
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?

zokemon 05-01-2008 05:30 PM

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 -



All times are GMT +2. The time now is 10:53 PM.

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