mortimer snodgrass
mortimer snodgrass

Reputation: 50

test for browser's ability to play a wav file in javascript

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

Answers (2)

Johni
Johni

Reputation: 2959

This should help you a lot: http://www.schillmania.com/projects/soundmanager2/

Upvotes: 2

AlexC
AlexC

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

Related Questions