FlashAudioPlugin Class
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 FlashAudioPlugin-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.FlashAudioPlugin.swfPath = "../src/soundjs/flashaudio";
createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin, createjs.FlashAudioPlugin]);
// Adds FlashAudioPlugin 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
Item Index
Methods
Properties
- _audioSources
- _capabilities static
- _container
- _CONTAINER_ID
- _flashInstances
- _flashPreloadInstances
- _REG_FLASHID static
- _UNREG_FLASHID static
- _volume
- _WRAPPER_ID
- buildDate static
- flash
- flashReady
- showOutput
- swfPath static
- version static
Methods
_generateCapabilities
()
private
static
Defined in
_generateCapabilities:238
Determine the capabilities of the plugin. Used internally. Please see the Sound API capabilities method for an overview of plugin capabilities.
_handleFlashReady
()
protected
Defined in
_handleFlashReady:304
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.
_handlePreloadComplete
-
event
Inherited from
AbstractPlugin:
_handlePreloadComplete:280
Handles internal preload completion.
Parameters:
-
event
Object
_handlePreloadError
-
event
Inherited from
AbstractPlugin:
_handlePreloadError:302
Handles internal preload errors
Parameters:
-
event
Object
_handleSWFReady
-
event
Defined in
_handleSWFReady:294
The SWF used for sound preloading and playback has been initialized.
Parameters:
-
event
ObjectContains a reference to the swf.
_updateVolume
()
Boolean
protected
Inherited from
AbstractPlugin
but overwritten in
_updateVolume:317
Available since 0.4.0
Internal function used to set the gain value for master audio. Should not be called externally.
Returns:
create
-
src
-
startTime
-
duration
Inherited from
AbstractPlugin:
create:213
Create a sound instance. If the sound has not been preloaded, it is internally preloaded here.
Parameters:
Returns:
A sound instance for playback and control.
getVolume
()
Number
Inherited from
AbstractPlugin:
getVolume:252
Get the master volume of the plugin, which affects all SoundInstances.
Returns:
The volume level, between 0 and 1.
isPreloadComplete
-
src
Inherited from
AbstractPlugin:
isPreloadComplete:175
Checks if preloading has finished for a specific source.
Parameters:
-
src
StringThe sound URI to load.
Returns:
isPreloadStarted
-
src
Inherited from
AbstractPlugin:
isPreloadStarted:164
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
StringThe sound URI to check.
Returns:
isSupported
()
Boolean
static
Defined in
isSupported:224
Determine if the plugin can be used in the current browser/OS.
Returns:
If the plugin can be initialized.
preload
-
loader
Inherited from
AbstractPlugin:
preload:154
Internally preload a sound.
Parameters:
-
loader
LoaderThe sound URI to load.
register
-
loadItem
Inherited from
AbstractPlugin:
register:132
Pre-register a sound for preloading and setup. This is called by Sound.
Note all plugins provide a Loader
instance, which PreloadJS
can use to assist with preloading.
Parameters:
-
loadItem
StringAn Object containing the source of the audio Note that not every plugin will manage this value.
Returns:
A result object, containing a "tag" for preloading purposes.
removeAllSounds
-
src
Inherited from
AbstractPlugin:
removeAllSounds:202
Remove all sounds added using WebAudioPlugin/register. Note this does not cancel a preload.
Parameters:
-
src
StringThe sound URI to unload.
removeSound
-
src
Inherited from
AbstractPlugin:
removeSound:185
Remove a sound added using WebAudioPlugin/register. Note this does not cancel a preload.
Parameters:
-
src
StringThe sound URI to unload.
setMute
-
value
Inherited from
AbstractPlugin:
setMute:261
Mute all sounds via the plugin.
Parameters:
Returns:
If the mute call succeeds.
setVolume
-
value
Inherited from
AbstractPlugin:
setVolume:239
Set the master volume of the plugin, which affects all SoundInstances.
Parameters:
-
value
NumberThe volume to set, between 0 and 1.
Returns:
If the plugin processes the setVolume call (true). The Sound class will affect all the instances manually otherwise.
Properties
_audioSources
Object
protected
Inherited from
AbstractPlugin:
_audioSources:65
Object hash indexed by the source URI of each file to indicate if an audio source has begun loading, is currently loading, or has completed loading. Can be used to store non boolean data after loading is complete (for example arrayBuffers for web audio).
_capabilities
Object
private
static
Defined in
_capabilities:200
The capabilities of the plugin. This is generated via the _generateCapabilities method. Please see the Sound capabilities method for a list of available capabilities.
_container
HTMLDivElement
protected
Defined in
_container:106
A reference to the DIV container that gets created to hold the Flash instance.
_CONTAINER_ID
String
protected
Defined in
_CONTAINER_ID:87
The id name of the DIV that gets created for Flash content.
Default: flashAudioContainer
_flashInstances
Object
protected
Defined in
_flashInstances:131
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
Defined in
_flashPreloadInstances:140
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.
_REG_FLASHID
String
private
static
Defined in
_REG_FLASHID:180
Event constant for the "registerFlashID" event for cleaner code.
Default: registerflashid
_UNREG_FLASHID
String
private
static
Defined in
_UNREG_FLASHID:190
Event constant for the "unregisterFlashID" event for cleaner code.
Default: unregisterflashid
_volume
Number
protected
Inherited from
AbstractPlugin:
_volume:83
The internal master volume value of the plugin.
Default: 1
_WRAPPER_ID
String
protected
Defined in
_WRAPPER_ID:96
Available since 0.4.1
The id name of the DIV wrapper that contains the Flash content.
Default: SoundJSFlashContainer
flash
Object | Embed
protected
Defined in
flash:114
A reference to the Flash instance that gets created.
flashReady
Boolean
Defined in
flashReady:122
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:74
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:211
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