开发者

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

开发者 https://www.devze.com 2023-03-31 10:26 出处:网络
Is there a way to test for browser\'s ability to play a wav file in javascript function playSound(myWAVfile)

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

精彩评论

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