Home > audioengine

audioengine

Audioengine is a project mainly written in ACTIONSCRIPT and JAVASCRIPT, it's free.

JS library to provide audio playback within the browser using HTML5 Audio tag with Flash fallback.

The AudioEngine API is accessed via JS whether it uses HTML5 or Flash.

Initialisation:

var audioEngine = new AudioEngine(optionsObject);

Constructor Options Object Properties

element (HTMLElement)

swf (String)

Path to AudioEngineFlashPlayer.swf relative to HTML document.

namespace (String)

preloadList (Array)

Array of Objects containing information required for the AudioEngine to preload the audio files. Object is required to have the following properties. {label:

onPreloadComplete (func)

Callback function called when audio files are preloaded and ready to start playing.

AudioEngine Public Methods

create(label, autoDestory, autoRewind, autoStop)

Creates a audio instance ready use to play pause and stop.

label (string) *required

Label that references the label declared in the preloadList in the options object supplied to the constructor. This will create a audio instance of this particular sound.

autoDestroy (Boolean) *optional default = true

When audio playback reaches the end the instance is destroyed. This is an ideal setting as Flash only supports 32 channels. If you wish to keep the sound alive for looping then set to false.

autoRewind (Boolean) *optional default = false

Sound is auto rewound when playback is completed.

autoStop (Boolean) *optional default = true

Sound is automatically stopped at the end of the playback, if set to false and autoRewind set to true then sound will loop.

returns an integer

This signifies the audio instance. This then can be used with the other methods to control specific instance, rather than use labels, which target all instances of that label.

play(label, audioInstanceID)

Method plays the sound associated with the label and or audioInstanceID.

label (String) *required

Label of sound to playback, if multiple instances of the sounds are created and only the label is supplied then play will target all of the instances associated with the label.

audioInstanceID (int) *optional

Using the instance returned by the create method, you can target a specific audio instance.

pause(label, audioInstanceID)

Method pauses the sound associated with the label and or audioInstanceID. Calling pause will not destroy the audio instance(s), and are available to re-play.

label (String) *required

Label of sound to pause, if multiple instances of the sounds are created and only the label is supplied then pause will target all of the instances associated with the label.

audioInstanceID (int) *optional

Using the instance returned by the create method, you can target a specific audio instance.

stop(label, audioInstanceID)

Method stops the sound associated with the label and or audioInstanceID, and destroys the audio instance(s).

label (String) *required

Label of sound to stop, if multiple instances of the sounds are created and only the label is supplied then pause will target all of the instances associated with the label.

audioInstanceID (int) *optional

Using the instance returned by the create method, you can target a specific audio instance.

stopAll()

Method stops and destroys all audio instances.

setVolume(volume)

Sets the global volume of the AudioEngine

volume (Float) *required

Set the global volume values range from 0 to 1.

Previous:Impedance_strat