SoundJS v1.0.0 API Documentation : HTMLAudioPlugin (original) (raw)

Play sounds using HTML tags in the browser. This plugin is the second priority plugin installed by default, after the WebAudioPlugin. For older browsers that do not support html audio, include and install the FlashAudioPlugin.

Known Browser and OS issues for HTML Audio

All browsers
Testing has shown in all browsers there is a limit to how many audio tag instances you are allowed. If you exceed this limit, you can expect to see unpredictable results. Please use Sound.MAX_INSTANCES as a guide to how many total audio tags you can safely use in all browsers. This issue is primarily limited to IE9.

IE html limitations

Safari limitations

iOS 6 limitations

Android Native Browser limitations

Android Chrome 26.0.1410.58 specific limitations

See Sound for general notes on known issues.

Constructor

Item Index

Methods

Properties

Methods

_generateCapabilities

() private static

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

_handlePreloadComplete

protected

Handles internal preload completion.

_handlePreloadError

protected

Handles internal preload errors

_updateVolume

() protected

Set the gain value for master audio. Should not be called externally.

create

(

)

AbstractSoundInstance

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

Parameters:

Returns:

getVolume

() Number

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

Returns:

Number:

The volume level, between 0 and 1.

isPreloadComplete

Boolean

Checks if preloading has finished for a specific source.

Parameters:

Returns:

isPreloadStarted

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:

Returns:

isSupported

() Boolean static

Determine if the plugin can be used in the current browser/OS. Note that HTML audio is available in most modern browsers, but is disabled in iOS because of its limitations.

Returns:

Boolean:

If the plugin can be initialized.

preload

Internally preload a sound.

Parameters:

register

Object

Pre-register a sound for preloading and setup. This is called by Sound. Note all plugins provide a Loader instance, which PreloadJScan use to assist with preloading.

Parameters:

Returns:

Object:

A result object, containing a "tag" for preloading purposes.

removeAllSounds

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

Parameters:

removeSound

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

Parameters:

setMute

Boolean

Mute all sounds via the plugin.

Parameters:

Returns:

Boolean:

If the mute call succeeds.

setVolume

Boolean

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

Parameters:

Returns:

Boolean:

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

Properties

_AUDIO_ENDED

String private static

Event constant for the "ended" event for cleaner code.

Default: ended

_AUDIO_READY

String private static

Event constant for the "canPlayThrough" event for cleaner code.

Default: canplaythrough

_AUDIO_SEEKED

String private static

Event constant for the "seeked" event for cleaner code. We utilize this event for maintaining loop events.

Default: seeked

_AUDIO_STALLED

String private static

Event constant for the "stalled" event for cleaner code.

Default: stalled

_audioSources

Object protected

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

The capabilities of the plugin. This is generated via the _generateCapabilitiesmethod. Please see the Sound capabilities method for an overview of all of the available properties.

_TIME_UPDATE

String private static

Event constant for the "timeupdate" event for cleaner code. Utilized for looping audio sprites. This event callsback ever 15 to 250ms and can be dropped by the browser for performance.

Default: timeupdate

_volume

Number protected

The internal master volume value of the plugin.

Default: 1

MAX_INSTANCES

Number static

The maximum number of instances that can be loaded or played. This is a browser limitation, primarily limited to IE9. The actual number varies from browser to browser (and is largely hardware dependant), but this is a safe estimate. Audio sprites work around this limitation.

Default: 30