Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play sound when receiving a web chat message

Tags:

jquery

How can I add simple sound when a message arrives in a web chat session with jQuery?

I noticed that they do it on the chat at http://chat.stackoverflow.com and I want to emulate that in my own software.

like image 205
good_evening Avatar asked Apr 28 '11 21:04

good_evening


1 Answers

jPlayer allows you to do this, and avoid Flash (with the HTML5 <audio> tag).

Edit:
As drachenstern noted in the comments, SO Chat actually uses jPlayer. Some code from the chat page:

<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&amp;fid=jqjp_flash_0&amp;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>
like image 167
entropo Avatar answered Oct 27 '22 21:10

entropo