API Documentation for: 0.6.0
Show:

SoundJS Module

Defined in: SoundJS:8

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 audio playback Plugins
  • Registering (and preloading) sounds
  • Creating and playing sounds
  • Master volume, mute, and stop controls for all sounds at once

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

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

Feature Set Example

 createjs.Sound.alternateExtensions = ["mp3"];
 createjs.Sound.on("fileload", this.loadHandler, this);
 createjs.Sound.registerSound("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 full sourcepath or event.src.
     instance.on("complete", this.handleComplete, this);
     instance.volume = 0.5;
 }

Browser Support

Audio will work in browsers which support WebAudio (http://caniuse.com/audio-api) or HTMLAudioElement (http://caniuse.com/audio). A Flash fallback can be added as well, which will work in any browser that supports the Flash player.