I am looking to integrate sound into a website. Basically a chat website where users will hear a sound when a new message arrives. What do you think is the best way to integrate sound?
Thank you for your time.
I would go with option #2. But, with a word of caution when integrating any sound into a web site, people often find it annoying, when a sound comes out of the blue.
The most elegant solution would be to use the upcoming HTML5
As as said by others, the alternative would be a Flash solution.
I would recommend using the
<audio> tag where possible and Flash as fallback content.
Personally I don't like background music or sounds on websites. Reminds me of the bad old days were every site had a background MIDI file on it.
At least have the option to switch it off :)
Please make a clearly visible mute button too! :)
Setting aside the ethics of whether to make a sound play in a web page automatically...
I've got this working with XHTML 1.0 Strict in FF 3.x+, Opera 9.x+, IE6+, but not in Chrome (22.214.171.124) or Safari (4.0.4). So, I can't figure out how to get Webkit to accept it. Note this likely will not pass XHTML validation. And also note that my doctype stuff starts off like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Anyway, although the following code doesn't work yet in Webkit browsers, it works in other browsers:
<bgsound src="http://example.com/sound.wav" loop="0" /> <audio src="http://example.com/sound.wav" autoplay loop="false" />
If anyone know how to get this working in Webkit browsers, I'd like to know how.