播放声音Javascript/Jquery [英] Play Sound Javascript/Jquery

查看:75
本文介绍了播放声音Javascript/Jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个基于Ajax的应用程序,该应用程序将在我们的本地Intranet网络上运行.

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

  1. 现在,每次从Ajax返回请求时,我都需要在客户端浏览器中播放声音.
  2. 我要将声音文件(mp3/wav)放在要下载应用程序的Web服务器(Tomcat)目录中 并在客户端浏览器上播放. (我不想嵌入它,只会自动播放)
  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. 我们的目标用户Intranet计算机无法访问外部Internet,因为这被我们的网络团队阻止.
  2. 大多数客户端在Windows XP上运行,并且Flash可能未更新或未安装.

我知道一些jQuery,但是我不知道我在想什么是可能的,以及我可以使用哪种可能的插件,基本上是跨浏览器.我的目标浏览器在IE6/IE7/IE8/FF3上运行.

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.

推荐答案

没有Flash且没有支持HTML5 <audio>标签的浏览器,即使不是没有可能,这也会很困难.

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

我的第一个想法只是建议 http://www.w3schools.com/html5/tag_audio.asp .用法

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();

但这在IE6 + 7中几乎也是不可能的.

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

这篇关于播放声音Javascript/Jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆