Sounds, IE7 and Security Warnings

Some of you may know that the last few weeks I've been writing an AJAX chat application that plugs in to DeskPRO. One of the problems we ran into is playing sound notifications. The problem is that IE7 likes to pop up a security warning when you use the usual <embed> code. This was unacceptable. So today I just want to briefly talk about how I solved the problem.

The solution that I came up with was to use Flash. Seeing as how over 98% of all users have Flash installed, it was the perfect solution.

I ended up finding an open source project called Sound Manager. You just embed the Flash movie on your page somewhere, and talk to it with plain old Javascript. You don't need Flash installed, you don't need to create your own movie -- all you do is use the API provided by Sound Manager.

For the curious ones amongst you, the API is really simple (taken directly from the linked page above):

Plain TextJAVASCRIPT:
  1. soundManager.createSound('myNewSound','/path/to/some.mp3');
  2.  
  3. soundManager.play('myNewSound');
  4. soundManager.setVolume('myNewSound',50);
  5. soundManager.setPan('myNewSound',-100);

The only problem I had with using Sound Manager is that it requires MP3's, and all of our sounds were WAV's. No biggie. Converting the files to MP3's was simple, and the resulting filesize a bit smaller anyway.

Even more accessible?

98% of internet users have Flash. That's a pretty good percentage. But I still wanted to make sure those rare 2% of users didn't get some "install this plugin" popup.

Basically what I ended up doing was using a Flash sniffer (some JS to determine if Flash is installed, and which version) to see if the user can use the Sound Manager. If they could use it, then great -- we're all set to go. If they couldn't, then the app reverts back to using good ol'd <embed>'s (except for IE7; no sound is better then an annoying security popup!).


Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically each day to your feed reader.

No comments yet.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)