Kurso You can detect the stream is alive in php with a simple piece of code which tries to open a port. Its good for connectivity issues and detecting if server is up and running :
<?php
if (!function_exists(__NAMESPACE__ . '\checkRemoteServerStatus'))
{
function checkRemoteServerStatus($streamingUrl,$interval,$offset = 0)
{
$ua = 'Mozilla/5.0 (X11 Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36';
$opts = array('http'=>array('method'=>'GET','header'=>'Icy-MetaData: 1','user_agent'=>$ua ));
if (1/*&&file_exists($streamingUrl)*/)
{
$context = stream_context_create($opts);
if ($stream = fopen($streamingUrl, 'r', false, $context)) {
$buffer = stream_get_contents($stream, $interval, $offset);
//echo $buffer;
if(strpos($buffer,"Server is currently up and public.") != false) {
return true;
} else {
if(strpos($buffer,"Server is currently down") == false) {
return -1;
} else {
return false;
echo "server is down";
}
}
fclose($stream);
return true;
}
} else {
echo "No URL specified.";
return false;
}
}
} else {
//echo "incorect URL";
return false;
}
//echo checkRemoteServerStatus('
http://mystream:27574/',19200,0);
?>