Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   Shoutcast Technical Support (http://forums.winamp.com/forumdisplay.php?f=86)
-   -   duration of song...? (http://forums.winamp.com/showthread.php?t=126411)

Opie-T 25th February 2003 22:59

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...

:igor:

GeraghtyJa 26th February 2003 12:53

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

Opie-T 27th February 2003 13:11

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...??

Jay 27th February 2003 19:22

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.

Opie-T 27th February 2003 21:13

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!:eek:

Tom 27th February 2003 21:21

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

Opie-T 27th February 2003 21:31

OK!
but how would can I get it through XML or the admin-page?

Tom 27th February 2003 21:36

Use: http://www.kription.com/scxml/recent.html
It will grab the XML info.

Tom

Opie-T 27th February 2003 21:38

Thanx! I'll check it out!

Opie-T 28th February 2003 14:20

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

Tom 28th February 2003 21:59

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

Opie-T 28th February 2003 23:11

no biggie... I'll just give a f***


All times are GMT. The time now is 16:12.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.