Hello everyone!
I'm working on a project that requires small flash player to stream an online shoutcast radio. Due to security reasons the flash player can stream only local files. So I had to come up with another solution... I found a php script that reads a shoutcast stream and outputs it in mp3 format.
Now my player works, but the sound is received with some "impurities", or "clicks"... I don't know how to call them. Basically, from ten to ten seconds there is a short annoying sound.
This is the script that I use:
PHP Code:
<?php
set_time_limit(0);
$streamname = "205.188.215.229";
$port = "8018";
$path = "/;stream.mp3";
header("Content-type: audio/mpeg");
$sock = fsockopen($streamname,$port);
fputs($sock, "GET $path HTTP/1.0\r\n");
fputs($sock, "Host: $streamname\r\n");
fputs($sock, "User-Agent: WinampMPEG/2.9\r\n");
fputs($sock, "Accept: */*\r\n");
fputs($sock, "Icy-MetaData:1\r\n");
fputs($sock, "Connection: close\r\n\r\n");
while(!feof($sock)) {
$buf = fread($sock, 1024 * 6);
echo $buf;
}
fclose($sock);
?>
If you add the path to this file in winamp or any other streaming player, you will hear the radio including the "impurities".
I'm sure it's the script's fault because if I try to listen to the radio directly the sound is pure. :confused:
I tied also
PHP Code:
fpassthru($sock);
instead of
PHP Code:
while(!feof($sock)) {
$buf = fread($sock, 1024 * 6);
echo $buf;
}
but ended up with the same result. Any help would be greatly appreciated!
Thanks!