SoundManager 2

I'll admit, it was somewhat tempting to label this "SoundManager 2.0! Ajax Edition Sound Platform! Beta! Now with more Ajax Goodness!", except that would have been terribly nonsensical, devaluing and inaccurate. (Besides, at time of writing, it's an alpha!)

Javascript Sound for The Web

SoundManager 2 project page The SoundManager 2 project page. Demos, of course, are included.

Back in 2002 I wrote SoundManager, a Javascript-to-Flash Sound library which allows web developers and front-end engineers to add sound effects via javascript in their web projects. It worked fairly nicely (save for a few Flash limitations,) and continues (at time of writing) to work.

However, there has been a growing need (read: number of e-mails received) for increased flexibility, better debugging and more options. With the Sound object and Flash 8's ExternalInterface support, somewhat more-reliable Javascript-to-flash (and vice versa) communication is possible, and SoundManager has been re-written to take advantage of some of these new features.

A Shiny New API

I suppose it is somewhat in the spirit of "web 2.0" that this library offers an API, uses Javascript and optionally, XML to get its job done - but that could have been said for the original version done back in 2002. Nonetheless, the library has been written with flexibility in mind and does sport some nifty new functionality.

Consider the following example, which allows creating of a sound object for later use:

 id: 'mySound',
 url: '/audio/mysoundfile.mp3',
 volume: 50,
 autoPlay: false,
 onprogress: function() { alert(this.bytesLoaded+'/'+this.bytesTotal+' bytes loaded,'); }
 onload: function() { alert(' loaded!'); }

The sound is ready to go, and can be started via'mySound'); - A number of other methods (play, pause, set pan, volume, stop) can be called as well.

A Brief Rant

This implementation is subject to some limitations, and I suspect Flash will always have a few restrictions on what it can do with sound; we will see what happens. Additionally, sound is not always a necessity on the web: Not every dialog, button or error message has to have its own unique annoyance. Use with discretion.

Related links