API Documentation for: 0.4.0

SoundJS Module

Defined in: SoundJS:3

The SoundJS library manages the playback of audio on the web. It works via plugins which abstract the actual audio implementation, so playback is possible on any platform without specific knowledge of what mechanisms are necessary to play sounds.

To use SoundJS, use the public API on the Sound class. This API is for:

  • Installing Plugins
  • Registering (and preloading) sounds
  • Playing sounds
  • Controlling all sounds volume, mute, and stopping everything

Please note that as of version 0.4.0, the "SoundJS" object only provides version information. All APIs from SoundJS are now available on the Sound class.

Controlling Sounds
Playing sounds creates SoundInstance instances, which can be controlled individually.

  • Pause, resume, and stop sounds
  • Control a sound's volume, mute, and pan
  • Add events to sound instances to get notified when they finish, loop, or fail

Feature Set Example

 createjs.Sound.addEventListener("loadComplete", createjs.proxy(this.loadHandler, this));
 createjs.Sound.registerSound("path/to/mySound.mp3|path/to/mySound.ogg", "sound");
 function loadHandler(event) {
     // This is fired for each sound that is registered.
     var instance = createjs.Sound.play("sound");  // play using id.  Could also use source.
     instance.addEventListener("playComplete", createjs.proxy(this.handleComplete, this));