Site hosted by Angelfire.com: Build your free website today!

Instructions : DNeX Flash Audio playhead : Minicaster FREE

ADVANCED INSTRUCTIONS

The following instructions are normally not required for basic use of the playhead. users wishing to change some of the default settings should read on..

Changing the configuration file during the page load operation

By default, the playhead looks for a file called 'XXX.xml' where XXX is the player's own filename. If you generate your configuration files dynamically using PHP or ASP, then you will need to tell the playhead to load this new URL. This can be done by adding a special variable to the page code, both in the OBJECT and the EMBED tags. If we wanted to tell 'player01.swf' to open a configuration file called 'dynamic.php', then you need to add this line to the OBJECT param list:-

<param name="flashVars" value="config=dynamic.php" />

and in the EMBED tag, add the variable definition

flashVars="config=dynamic.php"

You can specify any filename, but if you wish to use a URL containing non-alphabetical characters you MUST URLencode the name using RFC2396. For example, if your configuration file is at

http://www.myfiles.com/radioplayhead/config.php?music=madonna

then the URLencoded version is

http%3A//www.myfiles.com/radioplayhead/config.php%3Fmusic%3Dmadonna

There is a simple JavaScript encoder-decoder HERE.

Cross-Domain Policy Files

With Flash Player 7 and above, enhanced security prevents a Flash document from loading data (XML files) from another website unless that site has given permission. This means that a remote server hosting your configuration file must also publish a small XML file called "crossdomain.xml", that informs the Flash Player that they allow others to read their data. If this file is missing, Minicaster will display an error.

This is only a concern where the config file or a DNAS playlist is on a different website domain to your SWF playhead. If they are on the same domain, then a policy file is not needed.

For example, if our playhead is at

http://www.mysite.com/users.smith/minicaster.swf

Then it tries to load a configuration file from

Policy files are not needed to access MP3 data. For more information on the format of a Policy file, CLICK HERE.

Dynamically controlling the playhead with JavaScript

This playhead supports live updates to the config file location, to allow changes without a page refresh. To implement live updates and also play-pause control, add the following JavaScript to your page AFTER the Flash object:-

<script language="JavaScript"> <!-- function getFMP256(_swf) { return (navigator.appName.indexOf("Microsoft") != -1)? window[_swf]:document[_swf]; } function setconfig(_href) { getFMP256("fmp256").setconfig(_href); } function toggleplay() { getFMP256("fmp256").play(); } // --> </script>

To change the config file, an HTML hyperlink is used with a JavaScript event connected to the click, as below:-

<a href="#" onClick="setconfig('http://config.file/name.xml')">Change webcast</a>

You can toggle the play button (play-pause-play) using the second function, for example:-

<a href="#" onClick="toggleplay()">Play/pause music</a>

Using Minicaster with a Shoutcast DNAS cluster

It is perfectly possible to deliver a Shoutcast stream to our playhead, however there are some important issues that you must be aware of that will limit the playhead's operation:-

Firstly, Flash Player cannot connect to the 'root' of a Shoutcast server, as it is not possible to change the browser agent string passed by the plugin. Shoutcast uses this agent string to decide what is to be sent - if the agent string is a web browser, Shoutcast sends the server status page. If the agent string isn't a web browser it sends the MP3 stream. The user agent string cannot be changed in Flash Player - it is a security feature and is impossible to bypass. As a result if the server receives a connection to the root, it will not send the MP3 stream to Minicaster. If your Shoutcast server uses a folder name in the stream, then it will connect perfectly.

For example if your Shoutcast server's stream is linked to:-

http://my.shoutcast.xx:8000
then Minicaster will be unable to play the stream. If instead it is linked to:-
http://my.shoutcast.xx:8000/myradiostation
then Minicaster will play the stream. The server port number (in this case 8000) has no impact on this process, it is the presence of a folder name (such as 'myradiostation') that makes all the difference. This is not an issue with Icecast2 as the status pages for Icecast2 are only supplied if specifically requested by the browser.

It is impossible to collect the DNAS playlist file directly from Shoutcast, as there is no way for a Shoutcast server to send the 'crossdomain.xml' security policy file to Flash. It is possible to use a proxy script to pass the data through a normal webserver or to simply place a copy of the DNAS playlist file on another website and use that. Of course the webserver that runs your proxy script or hosts the DNAS playlist file has to contain the crossdomain.xml policy file as well, and in this case it must be available at the top level.

For example, suppose we have a Shoutcast stream running on a network of servers, all of which use a folder name so don't hit the problem we described above. We also have a 'normal' website at http://www.radio.com

We can collect the audio data OK, as it's got a folder name. We can put a copy of the DNAS playlist on the website and we can put the policy file online at http://www.radio.com/crossdomain.xml - so the config file ends up looking something like this:-

<?xml version="1.0" encoding="iso-8859-1" ?> <config version="1s" xmlns="http://www.draftlight.net/dnex/config/ns/0/"> <mp3cast> <playlist>http://www.radio.com/listen.pls</playlist> <website>http://www.radio.com/</website> <title>Title of my radio station</title> </mp3cast> <init autoplay="0" volume="80" reload="10" xfade="1" /> </config>