Reference to the current game instance.
ReadonlygameLocal reference to game.
Flag used to track if the game has lost focus.
ReadonlyjsonLocal reference to the JSON Cache, as used by Audio Sprites.
The Spatial Audio listener position.
Only available with WebAudio.
You can modify the x/y properties of this Vec2 directly to adjust the listener position within the game world.
ReadonlylockedMobile devices require sounds to be triggered from an explicit user action, such as a tap, before any sound can be loaded/played on a web page. Set to true if the audio system is currently locked awaiting user interaction.
Global mute setting.
Flag indicating if sounds should be paused when game looses focus, for instance when user switches to another tab/program/app.
Global playback rate at which all the sounds will be played. Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed and 2.0 doubles the audio's playback speed.
Global volume setting.
Adds a new sound into the sound manager.
Asset key for the sound.
Optionalconfig: SoundConfigAn optional config object containing default sound settings.
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
Asset key for the sound.
Optionalconfig: SoundConfigAn optional config object containing default sound settings.
Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: anyThe context to invoke the listener with. Default this.
Destroys all the sounds in the game and all associated events.
Calls each of the listeners registered for a given event.
The event name.
Additional arguments that will be passed to the event handler.
Return an array listing the events for which the emitter has registered listeners.
Gets all sounds in this Sound Manager.
You can optionally specify a key, in which case only Sound instances that match the given key will be returned.
Optionalkey: stringOptional asset key. If given, only Sound instances with this key will be returned.
When a key is given, returns true if any sound with that key is playing.
When no key is given, returns true if any sound is playing.
Sound asset key.
Return the number of listeners listening to a given event.
The event name.
Return the listeners registered for a given event.
The event name.
Remove the listeners of a given event.
The event name.
Optionalfn: FunctionOnly remove the listeners that match this function.
Optionalcontext: anyOnly remove the listeners that have this context.
Optionalonce: booleanOnly remove one-time listeners.
Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: anyThe context to invoke the listener with. Default this.
ProtectedonMethod used internally for pausing sound manager if Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true.
Add a one-time listener for a given event.
The event name.
The listener function.
Optionalcontext: anyThe context to invoke the listener with. Default this.
ProtectedonMethod used internally for resuming sound manager if Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true.
Pauses all the sounds in the game.
Adds a new sound to the sound manager and plays it.
The sound will be automatically removed (destroyed) once playback ends.
This lets you play a new sound on the fly without the need to keep a reference to it.
Asset key for the sound.
Optionalextra: SoundConfig | SoundMarkerAn optional additional object containing settings to be applied to the sound. It could be either config or marker object.
Adds a new audio sprite sound to the sound manager and plays it. The sprite will be automatically removed (destroyed) once playback ends. This lets you play a new sound on the fly without the need to keep a reference to it.
Asset key for the sound.
The name of the sound sprite to play.
Optionalconfig: SoundConfigAn optional config object containing default sound settings.
Removes a sound from the sound manager. The removed sound is destroyed before removal.
The sound object to remove.
Removes all sounds from the manager, destroying the sounds.
Remove all listeners, or those of the specified event.
Optionalevent: string | symbolThe event name.
Removes all sounds from the sound manager that have an asset key matching the given value. The removed sounds are destroyed before removal.
The key to match when removing sound objects.
Remove the listeners of a given event.
The event name.
Optionalfn: FunctionOnly remove the listeners that match this function.
Optionalcontext: anyOnly remove the listeners that have this context.
Optionalonce: booleanOnly remove one-time listeners.
Resumes all the sounds in the game.
Sets the X and Y position of the Spatial Audio listener on this Web Audios context.
If you call this method with no parameters it will default to the center-point of the game canvas. Depending on the type of game you're making, you may need to call this method constantly to reset the listener position as the camera scrolls.
Calling this method does nothing on HTML5Audio.
Optionalx: numberThe x position of the Spatial Audio listener.
Optionaly: numberThe y position of the Spatial Audio listener.
Sets the global playback rate at which all the sounds will be played.
For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed and 2.0 doubles the audios playback speed.
Global playback rate at which all the sounds will be played.
Removes all listeners.
Stops all the sounds in the game.
Stops any sounds matching the given key.
Sound asset key.
ProtectedunlockMethod used internally for unlocking audio playback on devices that require user interaction before any sound can be played on a web page.
Read more about how this issue is handled here in this article.
ProtectedupdateUpdate method called on every game step. Removes destroyed sounds and updates every active sound in the game.
The current timestamp as generated by the Request Animation Frame or SetTimeout.
The delta time elapsed since the last frame.
Base class for other Sound Manager classes.