API Documentation for: 1.0.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

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 Web Audio (http://caniuse.com/audio-api) or HTMLAudioElement (http://caniuse.com/audio). A Flash fallback can be used for any browser that supports the Flash player, and the Cordova plugin can be used in any webview that supports Cordova.Media. IE8 and earlier are not supported, even with the Flash fallback. To support earlier browsers, you can use an older version of SoundJS (version 0.5.2 and earlier).