Reputation: 9691
I'm building a jquery/html5 audio player and I have some problems on changing the source to the audio tag. The method I've implemented works on all browsers except IE9.
Here is a sample of code:
audio = $("<audio>").attr("id", "audioElement")
.attr("preload", "auto")
.appendTo(player);
function addMp3Source(sourceUrl) {
audio.empty();
var newSrc = $("<source>").attr("src", config.tracksURL + sourceUrl).appendTo(audio);
}
On IE9, the source is changing, but when I'm playing the track, it's the old sound that plays. On other browsers works fine.
Any ideeas?
Upvotes: 1
Views: 5116
Reputation: 364
function addMp3Source(sourceUrl) {
audio.empty();
var newSrc = $("<source>").attr("src", config.tracksURL + sourceUrl).appendTo(audio);
/****************/
audio[0].pause();
audio[0].load();//suspends and restores all audio element
/****************/
}
Upvotes: 1