A JavaScript Sound API supporting MP3, MPEG4 and HTML5 Audio.

SoundManager 2 speaker logo

SoundManager 2 makes it easier to play audio using JavaScript. Get SoundManager 2

Using HTML5 and Flash, SoundManager 2 provides reliable cross-platform audio under a single JavaScript API.


SM2 You!

How time flies; the SoundManager project is officially ten years old! It was born in late 2001, out of a need to have JavaScript-driven audio available in personal DHTML web experiments.

Since its release in 2006, SoundManager 2 has grown to become a full-fledged API used on major web sites, web-based games and applications not solely because it "just works," but because people like yourself choose to believe in it.

At some point in the future, native browser audio support will become consistent enough to make SM2 redundant; until then, the plan is to keep things going as long as there's a need and people find it useful.

SoundManager is still maintained by myself (with occasional patches via GitHub users,) and is supported entirely by good-will and nice emails from people who have found it useful over the years. Keep those coming. :)

It has been a personal goal to give something back to the web community which I learned so much from in the past, and continue to learn from today.

Thank you for your support!

— Scott "Schill" Schiller

Speak and be heard

More sound, in more places

Despite being one of the senses, sound has largely been missing from the web due to inconsistent technology support. SoundManager 2 bridges this gap, making it easier to use audio across a growing variety of devices and platforms, both desktop and mobile.

A few live examples:

HTML5 + flash hybrid

Complexity, reduced

Supporting HTML5 audio can be tedious in modern browsers, let alone legacy ones. With real-world visitors using browsers ranging from mobile Safari to IE 6 across a wide range of devices, there can be many support cases to consider.

SoundManager 2 gives you a single, powerful API that supports both new and old, using HTML5 audio where supported and optional Flash-based fallback where needed. Ideally when using SoundManager 2, audio "just works."

  • Desktop support: Windows, Mac OS, Linux
  • Laptop/tablet support: Windows, Mac OS, Linux / Blackberry Playbook, Kindle Fire + other HTML5/Flash devices
  • iPhone support: iOS 4.0 and newer
  • iPad support: Version 1.0 (iOS 3.2) and newer
  • Android platforms supporting HTML5 and/or Flash
The details: how it works »

The ginsu knife: 10 KB*

Big features, small footprint

But wait, there's more!

Performance is an important metric, too. SoundManager 2 packs a comprehensive, feature-rich API into as little as 10.9 KB over the wire when optimized; that's less than 8% of the original, uncompressed file size.

The source code is BSD-licensed and is provided in fully-commented, non-debug and compiler-optimized "minified" versions appropriate for development and production use.

* Gzip-compressed file size on a typical set-up is 10.9 KB. And was it supposed to be the Swiss Army kind? I forget.

Basic

Playable links and playlists

These demos use unordered lists with MP3 links that play in-place; the UI is easily customized via CSS.

A richer playlist theme with optional time, seekable progress bar and a VU meter where supported:

Shiny

Data visualization features

The 360° player UI demo uses <canvas> and includes options for waveform and spectrum analysis data via Flash 9, adding beautiful visual feedback to the interface.

Graffiti Sex courtesy of The Fugitives, from the album In Streetlight Communion.

Experimental

Advanced prototypes

No audio API is complete without at least one crazy demo. The "Wheels Of Steel" started as a simple CSS prototype, and evolved to replicate most of the UI and functionality of a traditional DJ set-up. Pitch bending, scratch and EQ effects are present where supported.

wheelsofsteel.net: Online turntable demo (screenshot)

The Wheels Of Steel, a browser-based DJ turntable prototype. For the tech details, read An Ode To Turntables (in HTML.)

Bonus

Additional demos

MPC (sampler/drum machine) + Smashable Christmas Lights

Examples showing multi-track playback, progress and combining sound with animation:

  • MPC (drum machine) demo screenshot
  • Smash Christmas Lights demo

"Audio sprites" (sound segments / samples) demo

With sound playback options like from and to, you can play portions of a larger, single-file "sprite" of many sounds.

"Fitter, Happier" waveform screenshot

For more live examples, see the API Demos.

Elsewhere

As heard on TV the internets

A few nifty places SoundManager 2 has been seen in use on the Wild World Web:

Articles and presentations

Some other words, pictures and video on the subject of HTML5 and web audio:

Credits and thank-yous

  • Icons: Desktop / mobile / iOS device iconography via glyphish.com (CC)
  • Music: Graffiti Sex courtesy of The Fugitives, from the album In Streetlight Communion.
    Blue Belle Lament courtesy of Adrian Glynn.
    I Tried and People Asking courtesy of SonReal.
  • Homepage header typeface: Chunk (Five) by Meredith Mandel (OFL)

Technical overview

HTML5 audio + optional Flash fallback

  • 100% Flash-free audio on iPad, iPhone (iOS4) and other HTML5-enabled devices + browsers
  • Invisible Flash SWF provides HTML5 fallback as needed
  • API is consistent whether using HTML5 or Flash
  • See useHTML5Audio for implementation details

API specifics

Basic API features (HTML5, Flash 8*)

  • Load, stop, play, pause, mute, seek, pan*, volume control from JavaScript
  • Events: onload(), whileloading(), whileplaying(), onfinish() and more
  • ID3V1 + ID3V2 tag support for MP3s (title, artist, genre etc.)*

Additional Flash 9-based API features

  • RTMP / Flash Media Server streaming support (experimental) - see serverURL
  • MPEG-4 (AAC, HE-AAC, H.264) audio support
  • "MultiShot" play (layered/chorusing effects)
  • Waveform/frequency spectrum data
  • Peak (L/R channel volume) data
  • Audio buffering state/event handling

Everything else

Documentation, tools and demos


Not only do you get the ginsu knife...

Even more demos and examples using the SoundManager 2 API...

Getting started

Basic SoundManager 2 set-up

Including the script, configuring soundManager.url (SWF file path) and registering an onready() callback:

<script src="soundmanager2.js"></script>
<script>
// where to find flash SWFs, if needed...
soundManager.url = '/path/to/swf-files/';

soundManager.onready(function() {
  // SM2 is ready to play audio!
});
</script>

Upon execution of soundmanager2.js, SM2 will determine what Flash SWF to load (if any) based on the path defined in soundManager.url.

After successful initialization, soundManager.onready() will fire and sounds can be played.

By default, SM2 uses a Flash 8-based SWF build. Some additional features are available when using the Flash 9-based build.

For a live example, see the basic template demo.

Playing audio

Basic playback control

Once soundManager.onready() has fired, sounds can be loaded and played.

Creating and playing a sound object

// create "mySound"...
soundManager.createSound({
  id: 'mySound',
  url: '/path/to/an.mp3'
});

// ...and play it
soundManager.play('mySound');

Additional options and events can be specified when loading and playing sounds. For more examples of playback features, see API Demos.