Skip to main content
Version: Phaser v4.0.0

HTML5AudioSoundManager

HTML5AudioSoundManager

Constructor

new HTML5AudioSoundManager(game)

Parameters

nametypeoptionaldescription
gamePhaser.GameNoReference to the current game instance.

Scope: static

Extends

Phaser.Sound.BaseSoundManager

Source: src/sound/html5/HTML5AudioSoundManager.js#L37
Since: 3.0.0

Inherited Members

From Phaser.Sound.BaseSoundManager:


Public Members

audioPlayDelay

audioPlayDelay: number

Description:

Value representing time difference, in seconds, between calling play method on an audio tag and when it actually starts playing. It is used to achieve more accurate delayed sound playback.

You might need to tweak this value to get the desired results since audio play delay varies depending on the browser/platform.

Source: src/sound/html5/HTML5AudioSoundManager.js#L58
Since: 3.0.0


loopEndOffset

loopEndOffset: number

Description:

A value by which we should offset the loop end marker of the looping sound to compensate for lag, caused by changing audio tag playback position, in order to achieve gapless looping.

You might need to tweak this value to get the desired results since loop lag varies depending on the browser/platform.

Source: src/sound/html5/HTML5AudioSoundManager.js#L73
Since: 3.0.0


mute

mute: boolean

Description:

Gets or sets the muted state of this Sound Manager. Setting this to true mutes all active sounds, while setting it to false restores their volume. Fires the GLOBAL_MUTE event when changed.

Overrides: Phaser.Sound.BaseSoundManager#mute

Fires: Phaser.Sound.Events#event:GLOBAL_MUTE

Source: src/sound/html5/HTML5AudioSoundManager.js#L389
Since: 3.0.0


override

override: boolean

Description:

Flag indicating whether if there are no idle instances of HTML5 Audio tag, for any particular sound, if one of the used tags should be hijacked and used for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play call should be ignored.

Source: src/sound/html5/HTML5AudioSoundManager.js#L45
Since: 3.0.0


volume

volume: number

Description:

Gets or sets the global volume of this Sound Manager. All active sounds will have their volume scaled by this value. Must be between 0 (silent) and 1 (full volume). Fires the GLOBAL_VOLUME event when changed.

Overrides: Phaser.Sound.BaseSoundManager#volume

Fires: Phaser.Sound.Events#event:GLOBAL_VOLUME

Source: src/sound/html5/HTML5AudioSoundManager.js#L438
Since: 3.0.0


Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.Sound.BaseSoundManager:


Public Methods

add

<instance> add(key, [config])

Description:

Adds a new sound into the sound manager.

Parameters:

nametypeoptionaldescription
keystringNoAsset key for the sound.
configPhaser.Types.Sound.SoundConfigYesAn optional config object containing default sound settings.

Overrides: Phaser.Sound.BaseSoundManager#add

Returns: Phaser.Sound.HTML5AudioSound - The new sound instance.

Source: src/sound/html5/HTML5AudioSoundManager.js#L142
Since: 3.0.0


destroy

<instance> destroy()

Description:

Calls Phaser.Sound.BaseSoundManager#destroy method and cleans up all HTML5 Audio related resources.

Overrides: Phaser.Sound.BaseSoundManager#destroy

Source: src/sound/html5/HTML5AudioSoundManager.js#L325
Since: 3.0.0


isLocked

<instance> isLocked(sound, prop, [value])

Description:

Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters to check if sound manager is locked and then either perform action immediately or queue it to be performed once the sound manager gets unlocked.

Access: protected

Parameters:

nametypeoptionaldescription
soundPhaser.Sound.HTML5AudioSoundNoSound object on which to perform queued action.
propstringNoName of the method to be called or property to be assigned a value to.
value*YesAn optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property.

Returns: boolean - Whether the sound manager is locked.

Source: src/sound/html5/HTML5AudioSoundManager.js#L340
Since: 3.0.0


onBlur

<instance> onBlur()

Description:

Method used internally for pausing sound manager if Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true.

Access: protected

Overrides: Phaser.Sound.BaseSoundManager#onBlur

Source: src/sound/html5/HTML5AudioSoundManager.js#L287
Since: 3.0.0


onFocus

<instance> onFocus()

Description:

Method used internally for resuming sound manager if Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true.

Access: protected

Overrides: Phaser.Sound.BaseSoundManager#onFocus

Source: src/sound/html5/HTML5AudioSoundManager.js#L307
Since: 3.0.0


setMute

<instance> setMute(value)

Description:

Sets the muted state of this Sound Manager.

Parameters:

nametypeoptionaldescription
valuebooleanNotrue to mute all sounds, false to unmute them.

Returns: Phaser.Sound.HTML5AudioSoundManager - This Sound Manager.

Fires: Phaser.Sound.Events#event:GLOBAL_MUTE

Source: src/sound/html5/HTML5AudioSoundManager.js#L371
Since: 3.3.0


setVolume

<instance> setVolume(value)

Description:

Sets the volume of this Sound Manager.

Parameters:

nametypeoptionaldescription
valuenumberNoThe global volume of this Sound Manager.

Returns: Phaser.Sound.HTML5AudioSoundManager - This Sound Manager.

Fires: Phaser.Sound.Events#event:GLOBAL_VOLUME

Source: src/sound/html5/HTML5AudioSoundManager.js#L420
Since: 3.3.0


unlock

<instance> unlock()

Description:

Unlocks HTML5 Audio loading and playback on mobile devices on the initial explicit user interaction.

Overrides: Phaser.Sound.BaseSoundManager#unlock

Source: src/sound/html5/HTML5AudioSoundManager.js#L162
Since: 3.0.0