Javascript play sound
I want to know is there any play to play s开发者_开发技巧ame wmv or mp3 from javascript, that will work for all the browsers? I had a look at HTML5 audio tag, but seems i need to add there .ogg, .mp3,.wav files to support all the browsers, though i need to have only one audio file.
Any idea?
Many Thanks, Hrayr
If you want the best cross-browser support, you should provide more than one encoding. It's very simple to generate the other versions using a free encoding tool like Audacity. Then, provide at least an mp3 and an ogg version of the resource (I wouldn't bother with wav) as this will cover all the browsers that support html5 audio. Then, if you want to provide a fallback option, like flash, you can cover all those users of non-html5 browsers who have the flash plug-in installed. You can use something like mediaelementjs to simplify the process of providing a unified player.
There probably is a way: http://jsmad.org/. It is a pure javascript mp3 decoder.
精彩评论