开发者

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)
    {   
      开发者_StackOverflow中文版  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);
    }


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


you can use html5

<audio id="audio-tag-element" controls="" src=myWAVfile tabindex="0"></audio>

Ie8 and less will not work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜