Reference to the current game instance.
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.
Global detuning of all sounds in cents. The range of the value is -1200 to 1200, but we recommend keeping it within a reasonable range for musical purposes.
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.
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.
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.
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.
Flag indicating if sounds should be paused when game loses 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.
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.
Adds a new sound into the sound manager.
Asset key for the sound.
Optionalconfig: SoundConfig
An optional config object containing default sound settings.
The new sound instance.
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: SoundConfig
An optional config object containing default sound settings.
The new audio sprite sound instance.
Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: any
The context to invoke the listener with. Default this.
this.
Calls Phaser.Sound.BaseSoundManager#destroy method and cleans up all HTML5 Audio related resources.
Calls each of the listeners registered for a given event.
The event name.
Additional arguments that will be passed to the event handler.
true if the event had listeners, else false.
Return an array listing the events for which the emitter has registered listeners.undefined
undefined
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: string
Optional asset key. If given, only Sound instances with this key will be returned.
ProtectedisMethod 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.
Sound object on which to perform queued action.
Name of the method to be called or property to be assigned a value to.
Optionalvalue: any
An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property.
Whether the sound manager is locked.
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.
The number of listeners.
Return the listeners registered for a given event.
The event name.
The registered listeners.
Remove the listeners of a given event.
The event name.
Optionalfn: Function
Only remove the listeners that match this function.
Optionalcontext: any
Only remove the listeners that have this context.
Optionalonce: boolean
Only remove one-time listeners.
this.
Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: any
The context to invoke the listener with. Default this.
this.
ProtectedonMethod used internally for pausing sound manager if Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true.
Add a one-time listener for a given event. The listener is automatically removed the first time the event is emitted, so it will never be called more than once.
The event name.
The listener function.
Optionalcontext: any
The context to invoke the listener with. Default this.
this.
ProtectedonMethod used internally for resuming sound manager if Phaser.Sound.HTML5AudioSoundManager#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 | SoundMarker
An optional additional object containing settings to be applied to the sound. It could be either config or marker object.
Whether the sound started playing successfully.
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: SoundConfig
An optional config object containing default sound settings.
Whether the audio sprite sound started playing successfully.
Removes a sound from the sound manager. The removed sound is destroyed before removal.
The sound object to remove.
True if the sound was removed successfully, otherwise false.
Removes all sounds from the manager, destroying the sounds.
Remove all listeners, or those of the specified event.
Optionalevent: string | symbol
The event name.
this.
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.
The number of matching sound objects that were removed.
Remove the listeners of a given event.
The event name.
Optionalfn: Function
Only remove the listeners that match this function.
Optionalcontext: any
Only remove the listeners that have this context.
Optionalonce: boolean
Only remove one-time listeners.
this.
Resumes all the sounds in the game.
Sets the global detuning of all sounds in cents. The range of the value is -1200 to 1200, but we recommend keeping it within a reasonable range for musical purposes.
The detuning value in cents. The range is -1200 to 1200, but we recommend keeping it within a reasonable range for musical purposes.
This Sound Manager.
Sets the X and Y position of the Spatial Audio listener on this Web Audio 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: number
The x position of the Spatial Audio listener.
Optionaly: number
The y position of the Spatial Audio listener.
Sets the muted state of this Sound Manager.
true to mute all sounds, false to unmute them.
This Sound Manager.
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.
This Sound Manager.
Sets the volume of this Sound Manager.
The global volume of this Sound Manager.
This Sound Manager.
Removes all listeners from this EventEmitter. This method is called automatically by the Scene Systems when the parent Scene shuts down, ensuring that all event bindings are cleared and no stale references remain.
Stops all the sounds in the game.
Stops any sounds matching the given key.
Sound asset key.
Unlocks HTML5 Audio loading and playback on mobile devices on the initial explicit user interaction.
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.
HTML5AudioSoundManager