<!DOCTYPE html>
<html>
<body>
<?PHP
$url ="http://www.yourwebradiostationaddress.com"; // webradio station address
$search = "icy-metaint"; // we search for 'icy-metaint'
$opts = array('http' => array('method' => 'GET', 'header' => 'Icy-MetaData: 1')); // set the options
$context = stream_context_create($opts); // create the stream context
if ($stream = fopen($url, 'r', false, $context)) // open the stream
{
$meta = stream_get_meta_data($stream); // read the meta-data
echo "<pre>"; // print the metatags
print_r($meta); // if you want
echo "</pre>";
$count = count($meta['wrapper_data']); // count the entries in the
$metaint = 0; // 'wrapper_data' array
for ($i = 0; $i < $count; $i++) // walk through the 'wrapper_data'
{ // array and search for the
if (stripos($meta['wrapper_data'][$i], $search) === 0) // 'icy-metaint' entry
{
$metaint = intval(trim(substr($meta['wrapper_data'][$i], strlen($search)), " :")); // read the metaint value
break;
}
}
if ($metaint > 0)
{
$size = ord(stream_get_contents($stream, 1, $metaint)) * 16; // skip the mp3 data, and read the
// size of the 'StreamTitle' data
echo "<br>Size: ".$size."<br>";
echo stream_get_contents($stream, $size); // read the 'StreamTitle' data
}
else
echo "No metaint data available";
fclose($stream); // close the stream
}
?>
</body>
</html>