Nicecast And The Web

If you've created a Nicecast audio stream, you probably want to get listeners for it. If you've got your own website, you can use that to promote your stream. This page provides a guide on various things you may wish to do. For further assistance, you'll want to speak to a qualified web developer.

Linking To Your Stream
If you just want to create a simple text link to your stream, just pull the address from the Share drawer, as found in next to the Internet setting. For example, if the address to the audio stream is http://www.example.com:8000/listen.m3u, the following HTML is used to create a link:
<a href="http://www.example.com:8000/listen.m3u">Click To Tune In</a>

On Air Test
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";
}

Now Playing Info
Finally, you may wish to display the title of the currently playing track, as well as previously played tracks.

To do this, you'll need to use the Recent Tracks Log (RTL) file (as seen in the Preferences window), coupled with PHP. Again, if you don't know anything about PHP, grab a book or check out the PHP.net. And as before, please note that we can't teach you PHP, and the information below is merely provided to assist you.
If you're running both your Nicecast server and your web server on your local machine, this is fairly easy. You just need to save the RTL file to somewhere in your web directory, and then access it. The following code opens the rtl.txt file, reads in the first line to the $buffer variable, and prints it out after the "Current Track:" text
$fp = fopen ("music/rtl.txt","r");
if (!feof($fp) )
{
$buffer = fgets($fp, 1024);
print "<tr><td align=\"center\"><b>Current Track</b>: $buffer";
}
fclose ($fp);

If you're using a remote web server, you'll need to find a way to get the RTL file up to that web server before it can be read. This is more difficult, and will likely require some sort of scripting. Research in AppleScript and other solutions will likely be the best bet. Good luck!

Embedding Content In A Webpage
It's possible to embed a stream in a webpage, with the following code:

`<audio autoplay="false" autobuffer="false" controls="true" src="http:// ADDRESS:PORT/listen"/>`

Be sure to replace ADDRESS:PORT with the correct information from the Internet address in your Share drawer. This will be something like 216.92.184.26:8000, so we'd use:

`<audio autoplay="false" autobuffer="false" controls="true" src="http:// 216.92.184.26:8000/listen"/>`

Add that code to your webpage, and users will be able to listen right from the page. Do note that this code will require a relatively modern web browser to work. If you need further assistance, please be sure to speak to a qualified professional web developer.