Skip to main content
Version: Phaser v4.0.0

NoAudioSoundManager

No-audio implementation of the Sound Manager. It is used if audio has been disabled in the game config or the device doesn't support any audio.

It represents a graceful degradation of Sound Manager logic that provides minimal functionality and prevents Phaser projects that use audio from breaking on devices that don't support any audio playback technologies.

Constructor

new NoAudioSoundManager(game)

Parameters

nametypeoptionaldescription
gamePhaser.GameNoReference to the current game instance.

Scope: static

Extends

Phaser.Sound.BaseSoundManager

Source: src/sound/noaudio/NoAudioSoundManager.js#L14
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.NoAudioSound - The new sound instance.

Source: src/sound/noaudio/NoAudioSoundManager.js#L51
Since: 3.60.0


addAudioSprite

<instance> addAudioSprite(key, [config])

Description:

Adds a new audio sprite sound into the sound manager. Audio Sprites are a combination of audio files and a JSON configuration. The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite

Parameters:

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

Overrides: Phaser.Sound.BaseSoundManager#addAudioSprite

Returns: Phaser.Sound.NoAudioSound - The new audio sprite sound instance.

Source: src/sound/noaudio/NoAudioSoundManager.js#L71
Since: 3.60.0


destroy

<instance> destroy()

Description:

Destroys all the sounds in the game and all associated events.

Overrides: Phaser.Sound.BaseSoundManager#destroy

Source: src/sound/noaudio/NoAudioSoundManager.js#L396
Since: 3.0.0


get

<instance> get(key)

Description:

Gets the first sound in the manager matching the given key, if any.

Tags:

  • generic
  • genericUse

Parameters:

nametypeoptionaldescription
keystringNoSound asset key.

Overrides: Phaser.Sound.BaseSoundManager#get

Returns: Phaser.Sound.BaseSound - - The sound, or null.

Source: src/sound/noaudio/NoAudioSoundManager.js#L93
Since: 3.23.0


getAll

<instance> getAll(key)

Description:

Gets any sounds in the manager matching the given key.

Tags:

  • generic
  • genericUse

Parameters:

nametypeoptionaldescription
keystringNoSound asset key.

Overrides: Phaser.Sound.BaseSoundManager#getAll

Returns: Array.<Phaser.Sound.BaseSound> - - The sounds, or an empty array.

Source: src/sound/noaudio/NoAudioSoundManager.js#L111
Since: 3.23.0


onBlur

<instance> onBlur()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would be called when the browser window loses focus and would pause all playing sounds if pauseOnBlur is enabled.

Overrides: Phaser.Sound.BaseSoundManager#onBlur

Source: src/sound/noaudio/NoAudioSoundManager.js#L224
Since: 3.0.0


onFocus

<instance> onFocus()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would be called when the browser window regains focus and would resume any sounds that were paused when focus was lost.

Overrides: Phaser.Sound.BaseSoundManager#onFocus

Source: src/sound/noaudio/NoAudioSoundManager.js#L236
Since: 3.0.0


onGameBlur

<instance> onGameBlur()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would be called when the Phaser Game instance loses focus (e.g. the canvas loses the pointer) and would pause sounds accordingly.

Overrides: Phaser.Sound.BaseSoundManager#onGameBlur

Source: src/sound/noaudio/NoAudioSoundManager.js#L248
Since: 3.0.0


onGameFocus

<instance> onGameFocus()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would be called when the Phaser Game instance regains focus and would resume any sounds that were paused on blur.

Overrides: Phaser.Sound.BaseSoundManager#onGameFocus

Source: src/sound/noaudio/NoAudioSoundManager.js#L260
Since: 3.0.0


pauseAll

<instance> pauseAll()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would pause all currently playing sounds.

Overrides: Phaser.Sound.BaseSoundManager#pauseAll

Source: src/sound/noaudio/NoAudioSoundManager.js#L272
Since: 3.0.0


play

<instance> play(key, [extra])

Description:

This method does nothing but return 'false' for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

Parameters:

nametypeoptionaldescription
keystringNoAsset key for the sound.
extraPhaser.Types.Sound.SoundConfig | Phaser.Types.Sound.SoundMarkerYesAn optional additional object containing settings to be applied to the sound. It could be either config or marker object.

Overrides: Phaser.Sound.BaseSoundManager#play

Returns: boolean - Always 'false' for the No Audio Sound Manager.

Source: src/sound/noaudio/NoAudioSoundManager.js#L129
Since: 3.0.0


playAudioSprite

<instance> playAudioSprite(key, spriteName, [config])

Description:

This method does nothing but return 'false' for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

Parameters:

nametypeoptionaldescription
keystringNoAsset key for the sound.
spriteNamestringNoThe name of the sound sprite to play.
configPhaser.Types.Sound.SoundConfigYesAn optional config object containing default sound settings.

Overrides: Phaser.Sound.BaseSoundManager#playAudioSprite

Returns: boolean - Always 'false' for the No Audio Sound Manager.

Source: src/sound/noaudio/NoAudioSoundManager.js#L147
Since: 3.0.0


remove

<instance> remove(sound)

Description:

Removes a sound from the sound manager. The removed sound is destroyed before removal.

Parameters:

nametypeoptionaldescription
soundPhaser.Sound.BaseSoundNoThe sound object to remove.

Overrides: Phaser.Sound.BaseSoundManager#remove

Returns: boolean - True if the sound was removed successfully, otherwise false.

Source: src/sound/noaudio/NoAudioSoundManager.js#L166
Since: 3.0.0


removeAll

<instance> removeAll()

Description:

Removes all sounds from the manager, destroying the sounds.

Overrides: Phaser.Sound.BaseSoundManager#removeAll

Source: src/sound/noaudio/NoAudioSoundManager.js#L182
Since: 3.23.0


removeByKey

<instance> removeByKey(key)

Description:

Removes all sounds from the sound manager that have an asset key matching the given value. The removed sounds are destroyed before removal.

Parameters:

nametypeoptionaldescription
keystringNoThe key to match when removing sound objects.

Overrides: Phaser.Sound.BaseSoundManager#removeByKey

Returns: number - The number of matching sound objects that were removed.

Source: src/sound/noaudio/NoAudioSoundManager.js#L193
Since: 3.0.0


resumeAll

<instance> resumeAll()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would resume all paused sounds.

Overrides: Phaser.Sound.BaseSoundManager#resumeAll

Source: src/sound/noaudio/NoAudioSoundManager.js#L283
Since: 3.0.0


setDetune

<instance> setDetune()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would set the global detune value for all sounds, measured in cents, where 100 cents equals one semitone.

Overrides: Phaser.Sound.BaseSoundManager#setDetune

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

Source: src/sound/noaudio/NoAudioSoundManager.js#L331
Since: 3.0.0


setMute

<instance> setMute()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would mute or unmute all sounds in the manager.

Source: src/sound/noaudio/NoAudioSoundManager.js#L345
Since: 3.0.0


setRate

<instance> setRate()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would set the global playback rate for all sounds, where 1 is normal speed, 0.5 is half speed, and 2 is double speed.

Overrides: Phaser.Sound.BaseSoundManager#setRate

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

Source: src/sound/noaudio/NoAudioSoundManager.js#L317
Since: 3.0.0


setVolume

<instance> setVolume()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would set the global volume for all sounds in the manager, where 0 is silent and 1 is full volume.

Source: src/sound/noaudio/NoAudioSoundManager.js#L356
Since: 3.0.0


stopAll

<instance> stopAll()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would stop all currently playing sounds.

Overrides: Phaser.Sound.BaseSoundManager#stopAll

Source: src/sound/noaudio/NoAudioSoundManager.js#L294
Since: 3.0.0


stopByKey

<instance> stopByKey(key)

Description:

Stops any sounds matching the given key.

Parameters:

nametypeoptionaldescription
keystringNoSound asset key.

Overrides: Phaser.Sound.BaseSoundManager#stopByKey

Returns: number - - How many sounds were stopped.

Source: src/sound/noaudio/NoAudioSoundManager.js#L209
Since: 3.23.0


unlock

<instance> unlock()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would attempt to unlock the audio context after a user gesture, which is required by modern browsers before audio playback can begin.

Overrides: Phaser.Sound.BaseSoundManager#unlock

Source: src/sound/noaudio/NoAudioSoundManager.js#L368
Since: 3.0.0


update

<instance> update()

Description:

This method does nothing for the No Audio Sound Manager, to maintain compatibility with the other Sound Managers.

In a real Sound Manager, this would be called on each game step to update the state of all active sounds.

Overrides: Phaser.Sound.BaseSoundManager#update

Source: src/sound/noaudio/NoAudioSoundManager.js#L305
Since: 3.0.0


Inherited Members

From Phaser.Sound.BaseSoundManager: