Possible Duplicate:
HTML5 audio element with dynamic source
I'm trying to get the player to reload a new track once the current one ends, but I think I might have done something wrong.
This is the player:
<audio id="audio" autoplay controls="controls" onclick="start()">
<source src="song.php" type="audio/mpeg" />
</audio>
Here's the script:
function start(){
var audio = document.getElementById('audio');
audio.play();
audio.addEventListener('ended',function(){
$.post("song.php", function(result){
audio.src = result;
audio.pause();
audio.load();
audio.play();
});
});
}
If I change the script to this, it works...but I don't want to reload the whole page:
function start(){
var audio = document.getElementById('audio');
audio.play();
audio.addEventListener('ended',function(){
window.location = 'player.html';
});
}