code PHP pour vérifier si ma webradio diffuse ou non
Posté : 05 sept. 2011, 15:47
Bonjour,
j'ai un problème avec un code PHP.
J'ai crée un site web pour ma webradio avec wordpress http://kokomo.fr
Le flux audio est accessible à l'adresse suivante http://82.67.46.243:8000/listen.m3u
J'ai ajouté un plugin à wordpress pour lire le code php : PHP Code Widget http://wordpress.org/extend/plugins/php-code-widget/
Mon but est d'afficher sur mon site si la radio diffuse ou non ; pour cela Nicecast (le logiciel de diffusion) propose une solution en PHP :
You may also like to display information on the On Air status of the stream. In order to display dynamic information on your website, you'll need to use something like PHP. The example below uses a simple PHP function, and basic HTML. If you don't know anything about PHP, now's the time to learn. Grab a book or check out the PHP.net. Please note, we can't teach you PHP, and the below is merely provided to aid you.
PHP Function:
function onAirTest($ipaddress, $port)
{
if ($ret = @fsockopen($ipaddress, $port, $errno, $errstr, 1))
{
fclose($ret);
return true;
}
else
{
return false;
}
}
Once this function is available (by sticking it at the top of the page, or in a PHP functions file for your site), it can be combined with a simple if/else statement as follows. Be sure to adjust the address (WWW.EXAMPLE.COM) and the name (MY STATION) as need. This setup can also be spruced up with graphics and alternate text as desired.
if (onAirTest("WWW.EXAMPLE.COM", "8000"))
{
print "MY STATION Is Currently On The Air";
}
else
{
print "MY STATION Is Currently Off The Air";
}
Mon soucis est que je n'arrive pas à adapter le code donné par Nicecast aux données de ma webradio , quand je rentre le code dans le widget et que je met en ligne je vois le code apparaitre et non le status "ON AIR" ! Alors que mettre à la place de WWW.EXAMPLE.COM", "8000"
merci d'avance pour votre aide
j'ai un problème avec un code PHP.
J'ai crée un site web pour ma webradio avec wordpress http://kokomo.fr
Le flux audio est accessible à l'adresse suivante http://82.67.46.243:8000/listen.m3u
J'ai ajouté un plugin à wordpress pour lire le code php : PHP Code Widget http://wordpress.org/extend/plugins/php-code-widget/
Mon but est d'afficher sur mon site si la radio diffuse ou non ; pour cela Nicecast (le logiciel de diffusion) propose une solution en PHP :
You may also like to display information on the On Air status of the stream. In order to display dynamic information on your website, you'll need to use something like PHP. The example below uses a simple PHP function, and basic HTML. If you don't know anything about PHP, now's the time to learn. Grab a book or check out the PHP.net. Please note, we can't teach you PHP, and the below is merely provided to aid you.
PHP Function:
function onAirTest($ipaddress, $port)
{
if ($ret = @fsockopen($ipaddress, $port, $errno, $errstr, 1))
{
fclose($ret);
return true;
}
else
{
return false;
}
}
Once this function is available (by sticking it at the top of the page, or in a PHP functions file for your site), it can be combined with a simple if/else statement as follows. Be sure to adjust the address (WWW.EXAMPLE.COM) and the name (MY STATION) as need. This setup can also be spruced up with graphics and alternate text as desired.
if (onAirTest("WWW.EXAMPLE.COM", "8000"))
{
print "MY STATION Is Currently On The Air";
}
else
{
print "MY STATION Is Currently Off The Air";
}
Mon soucis est que je n'arrive pas à adapter le code donné par Nicecast aux données de ma webradio , quand je rentre le code dans le widget et que je met en ligne je vois le code apparaitre et non le status "ON AIR" ! Alors que mettre à la place de WWW.EXAMPLE.COM", "8000"
merci d'avance pour votre aide