API Documentation for: 0.5.2
Show:

FlashPlugin Class

Defined in: FlashPlugin:41
Module: SoundJS

Play sounds using a Flash instance. This plugin is not used by default, and must be registered manually in Sound using the registerPlugins method. This plugin is recommended to be included if sound support is required in older browsers such as IE8.

This plugin requires FlashAudioPlugin.swf and swfObject.js, which is compiled into the minified FlashPlugin-X.X.X.min.js file. You must ensure that swfPath is set when using this plugin, so that the script can find the swf.

Example

 createjs.FlashPlugin.swfPath = "../src/SoundJS/";
 createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin, createjs.FlashPlugin]);
 // Adds FlashPlugin as a fallback if WebAudio and HTMLAudio do not work.

Note that the SWF is embedded into a container DIV (with an id and classname of "SoundJSFlashContainer"), and will have an id of "flashAudioContainer". The container DIV is positioned 1 pixel off-screen to the left to avoid showing the 1x1 pixel white square.

Known Browser and OS issues for Flash Audio

All browsers

  • There can be a delay in flash player starting playback of audio. This has been most noticeable in Firefox. Unfortunely this is an issue with the flash player and the browser and therefore cannot be addressed by SoundJS.

Constructor

FlashPlugin

()

Defined in FlashPlugin:41

Methods

_generateCapabilities

() protected static

Determine the capabilities of the plugin. Used internally. Please see the Sound API getCapabilities method for an overview of plugin capabilities.

_handleFlashReady

() protected

The Flash application that handles preloading and playback is ready. We wait for a callback from Flash to ensure that everything is in place before playback begins.

_handleSWFReady

(
  • event
)
protected

Defined in _handleSWFReady:317

The SWF used for sound preloading and playback has been initialized.

Parameters:

  • event Object

    Contains a reference to the swf.

_init

() protected

Defined in _init:272

An initialization function run by the constructor

_registerLoadedSrc

(
  • loadSrc
  • src
)
protected

Registers loaded source files to handle src being changed before loading. This occurs when there is a basePath added (by PreloadJS or internal Preloading.

Parameters:

_updateVolume

() Boolean protected

Defined in _updateVolume:483

Available since 0.4.0

Internal function used to set the gain value for master audio. Should not be called externally.

Returns:

create

(
  • src
)
SoundInstance

Defined in create:415

Create a sound instance. If the sound has not been preloaded, it is internally preloaded here.

Parameters:

  • src String

    The sound source to use.

Returns:

SoundInstance: A sound instance for playback and control.

getVolume

()

Defined in getVolume:495

Available since 0.4.0

Get the master volume of the plugin, which affects all SoundInstances.

Returns:

The volume level, between 0 and 1.

isPreloadStarted

(
  • src
)
Boolean

Checks if preloading has started for a specific source. If the source is found, we can assume it is loading, or has already finished loading.

Parameters:

  • src String

    The sound URI to check.

Returns:

isSupported

() Boolean static

Defined in isSupported:107

Determine if the plugin can be used in the current browser/OS.

Returns:

Boolean: If the plugin can be initialized.

preload

(
  • src
  • instance
)

Defined in preload:446

Preload a sound instance. This plugin uses Flash to preload and play all sounds.

Parameters:

  • src String

    The path to the Sound

  • instance Object

    Not used in this plugin.

register

(
  • src
  • instances
)
Object

Defined in register:359

Pre-register a sound instance when preloading/setup. Note that the FlashPlugin will return a Loader instance for preloading since Flash can not access the browser cache consistently.

Parameters:

  • src String

    The source of the audio

  • instances Number

    The number of concurrently playing instances to allow for the channel at any time.

Returns:

Object: A result object, containing a tag for preloading purposes.

removeAllSounds

(
  • src
)

Defined in removeAllSounds:398

Available since 0.4.1

Remove all sounds added using register. Note this does not cancel a preload.

Parameters:

  • src String

    The sound URI to unload.

removeSound

(
  • src
)

Defined in removeSound:382

Available since 0.4.1

Remove a sound added using register. Note this does not cancel a preload.

Parameters:

  • src String

    The sound URI to unload.

setMute

(
  • value
)
Boolean

Defined in setMute:505

Available since 0.4.0

Mute all sounds via the plugin.

Parameters:

  • value Boolean

    If all sound should be muted or not. Note that plugin-level muting just looks up the mute value of Sound getMute, so this property is not used here.

Returns:

Boolean: If the mute call succeeds.

setVolume

(
  • value
)
Boolean

Defined in setVolume:470

Available since 0.4.0

Set the master volume of the plugin, which affects all SoundInstances.

Parameters:

  • value Number

    The volume to set, between 0 and 1.

Returns:

Boolean: If the plugin processes the setVolume call (true). The Sound class will affect all the instances manually otherwise.

Properties

_audioSources

Object protected

Defined in _audioSources:159

An object hash indexed by ID that indicates if each source is loaded or loading.

_capabilities

Object protected static

Defined in _capabilities:73

The capabilities of the plugin. This is generated via the _generateCapabilities method. Please see the Sound getCapabilities method for a list of available capabilities.

_container

HTMLDivElement protected

Defined in _container:199

A reference to the DIV container that gets created to hold the Flash instance.

_CONTAINER_ID

String protected

Defined in _CONTAINER_ID:176

The id name of the DIV that gets created for Flash content.

Default: flashAudioContainer

_flashInstances

Object protected

Defined in _flashInstances:224

A hash of SoundInstances indexed by the related ID in Flash. This lookup is required to connect sounds in JavaScript to their respective instances in Flash.

_flashPreloadInstances

Object protected

A hash of Sound Preload instances indexed by the related ID in Flash. This lookup is required to connect a preloading sound in Flash with its respective instance in JavaScript.

_preloadInstances

Object protected

Defined in _preloadInstances:242

Available since 0.4.0

A hash of Sound Preload instances indexed by the src. This lookup is required to load sounds if internal preloading is tried when flash is not ready.

_queuedInstances

Object protected

An array of Sound Preload instances that are waiting to preload. Once Flash is initialized, the queued instances are preloaded.

_volume

Number protected

Defined in _volume:167

The internal volume value of the plugin.

Default: 1

_WRAPPER_ID

String protected

Defined in _WRAPPER_ID:185

Available since 0.4.1

The id name of the DIV wrapper that contains the Flash content.

Default: SoundJSFlashContainer

BASE_PATH

String deprecated static

Defined in BASE_PATH:84

Deprecated in favor of swfPath
The path relative to the HTML page that the FlashAudioPlugin.swf resides. Note if this is not correct, this plugin will not work.

Default: null

buildDate

String static

Defined in buildDate:19

The build date for this release in UTC format.

flash

Object | Embed protected

Defined in flash:207

A reference to the Flash instance that gets created.

flashReady

Boolean

Defined in flashReady:215

Determines if the Flash object has been created and initialized. This is required to make ExternalInterface calls from JavaScript to Flash.

Default: false

showOutput

Boolean

Defined in showOutput:261

A developer flag to output all flash events to the console (if it exists). Used for debugging.

 createjs.Sound.activePlugin.showOutput = true;

Default: false

swfPath

String static

Defined in swfPath:96

Available since 0.5.2

The path relative to the HTML page that the FlashAudioPlugin.swf resides. Note if this is not correct, this plugin will not work.

Default: src/SoundJS

version

String static

Defined in version:10

The version string for this release.