Set a default file
Goal: Set a default file.
test1: sound at default bitrate - test2: long local sound at 128kbps - test3: external sound at 56kbps
Javascript function
<script language="JavaScript">
function play(url, bitrate) {
var default_bitrate = 32;
if (bitrate==undefined) { bitrate=default_bitrate; }
var p = window.document.mp3player;
p.SetVariable("my_bitrate", bitrate);
p.SetVariable("url", url);
}
function DefaultFile() {
// we test if the flash movie is found AND loaded (by checking the global variable
'my_once"
if ( (document.mp3player) && (document.mp3player.GetVariable('my_once')=='false')
) {
clearInterval(mytest); // player loaded and ready, we clear the repetitive test
play('sounds/amberwaves.mp3', '128'); // we play our default sound
} else {
return; // player not ready to play, have to wait a litlle bit more
}
}
mytest = setInterval('DefaultFile()', 100); // launch a test every 100ms to test
if flash player is ready
<
/script>
Note : we don't use "onload" function in <body> tag because in some browser we have no assurance the player is ready to play