开发者

Playing a sound in an AJAX chat

I am using the Audio class to play a sound in an AJAX chat when there's a new message. My code:

if ( ! $.browser.msie || ( $.browser.msie && parseFloat(jQuery.browser.version) >= 9 ) )
{
   //var notif = new Audio('http://cycle1500.com/sounds/infbego.wav');      
   var notif = new Audio('/media/sounds/drip.wav');     
   notif.play();
}
  1. I am checking the version of IE because only 9 seems to support HTML5 audio. Is there a better way to do it?
  2. var notif = new Audio('http://c开发者_Go百科ycle1500.com/sounds/infbego.wav'); works var notif = new Audio('/media/sounds/drip.wav'); doesn't work

    Why not?

  3. Where can I find documentation on how to construct the Audio class?


You can use HTML5 <audio> tag in you application, this will be supported in recent browser version and to support older version you can create fallback.

Clear and beautiful documentation is here.Have a look .
http://html5doctor.com/native-audio-in-the-browser/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜