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

## What SoundManager 2 does

Audio features, accessible from JavaScript.

### About SoundManager 2, Features and Live Demos

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

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

### 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.

### Complexity, reduced

Supporting HTML5 audio in modern browsers can be tedious, let alone "legacy" HTML4-based ones. With technology ranging from mobile Safari down to IE 6, there's a lot of ground to cover.

SoundManager 2 gives you a simple but powerful API that supports both new and old, using HTML5 audio where supported and an invisible Flash fallback where needed. Ideally when using SoundManager 2, audio "just works."

### Less talk, more shiny

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

#### Inline demos using SoundManager 2

Office lobby sound
Random
Water Drop
360° UI »
coins.mp3 glass0.mp3 glass1.mp3
mp3 buttons »
The Fugitives - Graffiti Sex

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

360° + spectrum UI »

- Armstrong Beat
- Untitled Groove
- BC Quail (HE-AAC)

- Ghosts+Goblins Reconstructed (OGG)
- A corked beer bottle (WAV)

muxtape-style UI »

#### Not only do you get the ginsu knife...

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

- Playable MP3 links
- MPC sampler/drum machine
- Basic animation + sound
- Smashable christmas lights
- Live API + code examples

### Big features, small footprint

SoundManager 2 packs a full-featured API (100 KB of code) into as little as 10 KB over the wire. The source is provided in fully-commented, -no-debug and compiler-optimized "minified" versions appropriate for development and production use.

### Technical details

#### HTML5 Audio Support (Beta-ish)

- 100% Flash-free MP3 + MP4/AAC where supported. Works on iPad, iPhone (iOS4)
- Seamless flash fallback for MP3/MP4 content, if needed
- HTML5/Flash API switching is transparent, handled internally
- WAV + OGG playback possible via HTML5, if supported
- See useHTML5Audio for implementation details
- Want more on the state of HTML5 audio? Read the article (12/2010), or watch the video talk + turntable demo (05/2011)

#### 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 and ID3V2 tag support for MP3s (title, artist, genre etc.)*

#### Shiny Flash 9-only 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

#### General Tech Stuff

- Extensive API Documentation with examples and notes
- console.log()-style debug output and troubleshooting tools
- Community-based discussion/support

#### As Heard On TV The Internets

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

- SoundCloud / The Cloud Player
- last.fm
- Opera Software ASA
- 8tracks
- Discogs
- The Hype Machine
- NON-STOP NYAN CAT!
- Turntable.fm
- Audiogalaxy

#### Download!

Get SoundManager 2

## Playing MP3s with JavaScript

Play audio in one line, or get fancy with multiple options.

### How To Play Audio Using SoundManager 2

Simple ID / URL method:

`soundManager.play('mySound','/path/to/an.mp3');`

And, setting the volume:

`soundManager.setVolume('mySound',50);`

More flexible method supporting option parameters as an object literal:

    var mySound = soundManager.createSound({
      id: 'someSound',
      url: '/path/to/some.mp3',
      volume: 50,
      onload: soundLoadedFunction
    });
    mySound.play();

See API Demos

## Using SM2 on your site

How to include SoundManager 2 from HTML, and some basic event handlers.

Include the SoundManager 2 core script, tell it where to look for the flash .SWF and provide an `onready()` callback.

    <script src="/path/to/soundmanager2.js"></script>
    <script>
    soundManager.url = '/path/to/swfs/';
    soundManager.onready(function() {
      // SM2 is ready to go!
      // soundManager.createSound(...) calls can now be made, etc.
    });
    </script>

See a basic template demo

## Licensing

BSD licensed.

SoundManager 2 is provided under a BSD license.

## Discussion / Support

Get Satisfaction support network

SM2 options: +html5 | -html5 | +debug