I am currently trying to play various wav files on my website. I am currently using an HTML5 element <audio>, but I am also trying to get some backward compatibility since IE will not play wavs through the audio tag.
I created a javascript function that creates the corresponding sound object <embed>:
function createPreHtml5EmbedItem(callID, parent) {
$("#sound").remove();
var sound = $("<embed id='sound' controls='console' type='audio/wav' />");
sound.attr('src', '/recording?id=' + callID);
sound.attr('loop', false);
sound.attr('hidden', false);
sound.attr('autostart', true);
parent.append(sound);
}
Everything works fine, but when I press another button, I would like to stop playing this sound element. In firefox, I can do this:
function stopAudioPreHtml5() {
$("#sound").remove();
}
but for some reason this does not work in IE. Is there a way to stop the current item <embed>before I delete it?
source
share