当消息到达jQuery的网络聊天会话时,如何添加简单的声音?
我注意到他们是在http://chat.stackoverflow.com的聊天中进行的,我想在自己的软件中模仿它。
答案 0 :(得分:5)
jPlayer允许您执行此操作,并避免使用Flash(使用HTML5 <audio>
标记)。
修改强>
正如drachenstern在评论中指出的那样,SO Chat实际上使用了jPlayer。聊天页面中的一些代码:
<div id="jplayer" style="position: absolute; top: 0px; left: 0px;">
<embed name="jqjp_flash_0" id="jqjp_flash_0" src=
"http://or.sstatic.net/chat/Jplayer.swf" width="0" height="0" bgcolor="#FFFFFF"
quality="high" flashvars="id=jplayer&fid=jqjp_flash_0&vol=80"
allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage=
"http://www.macromedia.com/go/getflashplayer" />
<div id="jqjp_force_0" style="text-indent: -9999px;">
0.7310569109395146
</div>
</div>
答案 1 :(得分:3)
您是否考虑使用控制Flash元素的jQuery Sound plugin?
这是一个简单的声音播放器,它使用闪光灯播放声音,但不为任何控件提供闪存接口,一切都通过jQuery控制
$("#sound").sound({swf: url});
$("#sound").load(url);
$("#sound").play();
$("#sound").pause();
$("#sound").stop();
$("#sound").volume(0-100);