开发者

Play Sound Javascript/Jquery

I am building an Ajax Based application that will run on our local intranet network.

  1. Now upon every return of request from my Ajax, I need to play a sound in my client browser.
  2. I want to put a sound file (mp3/wav) in my web server (Tomcat) directory where the application will download and play at the client browser. (I dont want to embed this and will just automatically play)

But I basically have this limitation.

  1. Our 开发者_如何转开发target users intranet computers has no access to the outside internet since this is being block by our network team.
  2. Most of the client runs on Windows XP and Flash might not be updated or not being installed.

I know a little jQuery but I dont know if what I am thinking is possible and what possible plugin can I use that is basically cross browser. My target browse runs on IE6/IE7/IE8/FF3.


Without flash and without a browser that supports HTML5 <audio> tags, that is going to be tough if not impossible.

My first idea was just to suggest http://www.w3schools.com/html5/tag_audio.asp. Usage

<audio src="/sound/ajax.mp3" id="ajaxdone"/>

// ajax success / readystate == 4
var mysound = $('#ajaxdone')[0];
    mysound.play();

But that is also pretty much impossible in IE6 + 7.


In IE You could use <BGSOUND src= loop="1"> tag - append it and remove it before adding another.

I'm not sure which browsers accept that tag, and it's deprecated.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜