var music = new Array();
music[0] = 'nirvana-comeasyouare.wav';
music[1] = 'nirvana-lithium.wav';
music[2] = 'bonjoviitsmylife.wav';
var songNum = 0;
function alter_player(what_to_do) {
var myPlayer = document.getElementById('use_this');
if(what_to_do == 'play') {
myPlayer.play();
document.getElementById('chosen_action').innerHTML = 'Playing song ' + (songNum+1) + ' of ' + music.length;
}
if(what_to_do == 'stop') {
myPlayer.stop();
document.getElementById('chosen_action').innerHTML = 'Stop';
}
if(what_to_do == 'next') {
myPlayer.stop();
songNum++;
if (songNum == music.length) songNum = 0; // If we've reached past the last song, loop around to the first
myPlayer = reinitialise_player('[URL unfurl="true"]http://www.freewebs.com/foxandhounds/'[/URL] + music[songNum]);
document.getElementById('chosen_action').innerHTML = 'Playing song ' + (songNum+1) + ' of ' + music.length;
}
if(what_to_do == 'previous') {
myPlayer.stop();
songNum--;
if (songNum == -1) songNum = music.length-1; // If we've reached past the first song, loop around to the last
myPlayer = reinitialise_player('[URL unfurl="true"]http://www.freewebs.com/foxandhounds/'[/URL] + music[songNum]);
document.getElementById('chosen_action').innerHTML = 'Playing song ' + (songNum+1) + ' of ' + music.length;
}
}
function reinitialise_player(url) {
var myPlayer = document.getElementById('use_this');
myPlayer.parentNode.removeChild(myPlayer);
document.getElementsByTagName('body')[0].appendChild(myPlayer = document.createElement('embed'));
with (myPlayer) {
setAttribute('src', url);
setAttribute('height', '100');
setAttribute('width', '100');
setAttribute('hidden', 'true');
setAttribute('autostart', 'true');
setAttribute('id', 'use_this');
setAttribute('name', 'use_this');
setAttribute('mastersound', '');
}
return(myPlayer);
}