Reputation: 50
Is there a way to test for browser's ability to play a wav file in javascript
function playSound(myWAVfile)
{
if (soundEmbed)
{
document.body.removeChild(soundEmbed);
}
soundEmbed = document.createElement("embed");
soundEmbed.setAttribute("src", myWAVfile);
soundEmbed.setAttribute("hidden", true);
soundEmbed.setAttribute("autostart", true);
document.body.appendChild(soundEmbed);
}
Upvotes: 0
Views: 682
Reputation: 2959
This should help you a lot: http://www.schillmania.com/projects/soundmanager2/
Upvotes: 2
Reputation: 9661
you can use html5
<audio id="audio-tag-element" controls="" src=myWAVfile tabindex="0"></audio>
Ie8 and less will not work
Upvotes: 0