PDA

View Full Version : Integration of nicecast "on air" feature in pixelpost


cilwang
04-27-2007, 12:53 PM
Hi everyone, I'm Cyril and new to this forum but not to pixelpost since I've been using this wonderful app for 2 years now with infinite pleasure ! than you to all you guys who made my "dream photobloggin app" possible (not even mentionning the 1.6 version which is something like "rhha lovely" :-) ).

Now I have a question to submit to you users !

I have been using for a moment the fantastic rogue Amoeba app called nicecast (http://www.rogueamoeba.com/nicecast/) that turns your computer into a broadcating machine from any audio source from your comp... It has a build in server and I would like to let people know when I am broadcasting on my website running pixelpost, by displaying a "radio online" or "radio offline" text... Problem is that I'm not fond of php and I'm not sure how to integrate this, although it doesn't seem complicated. Maybe you can help me ?

here is how it work, I'm copy pasting the tutorial from rogue amoeba, but I don't know where to put these functions, how ton integrate them, and how to call it in the image_template.html file of my template :


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 (index.php in pixelpost ???????), 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";
}



I'm thanking you in advance for the help !


Cyril - http://www.unjouraparis.com

jaywilliams
04-27-2007, 01:24 PM
It sounds like you need to make a simple little addon.

It's not very hard to do. (Wiki Help Section (http://wiki.pixelpost.org/index.php?title=How_could_I_write_my_own_addon_for _Pixelpost%3F))

You could remove the function wrapper, and have it just run in the addon code. Then make the script output a variable. The variable that it outputs can be used to make your very own template tag.


A note of caution:
You may want to consider using some caching techniques, as pinging your server every time the page loads will slow down your page loading time considerably when the server is offline.

cilwang
04-27-2007, 04:33 PM
thank you for this fast and clear answer. time to try now :-)