Old 25th February 2003, 22:59   #1
Opie-T
Junior Member
 
Join Date: Jan 2001
Posts: 15
duration of song...?

is it possible to get the duration of the song from shoutcast using php? and if... How?

Or does this only work with SAM...

Opie-T is offline   Reply With Quote
Old 26th February 2003, 12:53   #2
GeraghtyJa
Senior Member
 
GeraghtyJa's Avatar
 
Join Date: Feb 2003
Location: NYC Metro
Posts: 209
yes there are several neat little things you can use to do this, check out radiotoolbox, you will find the link in the FAQ's
GeraghtyJa is offline   Reply With Quote
Old 27th February 2003, 13:11   #3
Opie-T
Junior Member
 
Join Date: Jan 2001
Posts: 15
I'm actually looking for just a php-script, I can include in my original script... (A script showing track-name etc...) All I'm missing is the script for the duration of the song (Mins, seconds) to show up... But I don't know how to get this from the server...??
Opie-T is offline   Reply With Quote
Old 27th February 2003, 19:22   #4
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
Quote:
Originally posted by Opie-T
... But I don't know how to get this from the server...??
XML or the main admin page, it's fairly simple.
Jay is offline   Reply With Quote
Old 27th February 2003, 21:13   #5
Opie-T
Junior Member
 
Join Date: Jan 2001
Posts: 15
here's a code sniplet I use...

// Connect to server
$fp=fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo "error in fsockopen<br>\n$errno - ($errstr)<br>\n";
}

// Get data from server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// exit if connection broken
for($i=0; $i<30; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(500000);
}

// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);

// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song,) = explode(",", $fp_data);


where exactly would I find the duration and how would I convert it to mins, secs...? Hope you can help!
Opie-T is offline   Reply With Quote
Old 27th February 2003, 21:21   #6
Tom
Moderator
 
Join Date: Apr 2000
Posts: 4,491
SHOUTcast doesn't report the song length. The best you can do with the data SHOUTcast provides is determine the song length of previously played files by subtracting playedat times.

Tom
Tom is offline   Reply With Quote
Old 27th February 2003, 21:31   #7
Opie-T
Junior Member
 
Join Date: Jan 2001
Posts: 15
OK!
but how would can I get it through XML or the admin-page?
Opie-T is offline   Reply With Quote
Old 27th February 2003, 21:36   #8
Tom
Moderator
 
Join Date: Apr 2000
Posts: 4,491
Use: http://www.kription.com/scxml/recent.html
It will grab the XML info.

Tom
Tom is offline   Reply With Quote
Old 27th February 2003, 21:38   #9
Opie-T
Junior Member
 
Join Date: Jan 2001
Posts: 15
Thanx! I'll check it out!
Opie-T is offline   Reply With Quote
Old 28th February 2003, 14:20   #10
Opie-T
Junior Member
 
Join Date: Jan 2001
Posts: 15
Okay... the XML grabber worked to get the current playing, listener info etc... but how can I make it show the duration (how many mins, secs) of song...

Ex:
Now playing: Eminem - 8 mile
Track length: 6:00
Opie-T is offline   Reply With Quote
Old 28th February 2003, 21:59   #11
Tom
Moderator
 
Join Date: Apr 2000
Posts: 4,491
As I said earlier you will not be able to determine the length of the currently playing track, however by subtracting playedat times you can get the duration of previously played tracks.

Tom
Tom is offline   Reply With Quote
Old 28th February 2003, 23:11   #12
Opie-T
Junior Member
 
Join Date: Jan 2001
Posts: 15
no biggie... I'll just give a f***
Opie-T is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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