Few days ago I was creating a system in which it was necessary to implement a sound notification feature. Well it’s not very hard task but of course you have to be careful with the browser compatibility. At first my source was something like that:
Actually in my Linux it was working pretty well (I tried it mainly in Chrome).
After that I decided to try it in a different environment (OS, browser…). Well I started the app in Google Chrome installed on Windows 7. It was working again :). After that…IE…and yes it wasn’t working (the browser asked me to start an add-on but this stinks…). Well IE has a tag for background sound. So I added:
In the JS I’ve added:
I tried the script in Firefox…It asked me if I want to install Quick time plugin…I refused and there wasn’t any sound. Great, isn’t it? I tried it in Safari…no sound…
As you know in HTML5 you have an audio tag. If you use new browser you can use this tag and I think that it’s the best way for sound notification here is it:
The audioSupported property is the result of the:
But if the browser is too old it don’t have html5 implemented so…you need something else. Well almost all users have a Flash player. So it’s a good idea to use it for our goal (here you need *.swf copy of the sound file):
You can check whether there is a flash player installed with:
Here is the result:
Of course if the user use old version of firefox, don’t have a flash player and quick time player plugin installed this method is going to fail :). So it’s under development but it’s quite good way of notifying with sound.