Reference to the current sound manager instance.
Asset key for the sound.
Optionalconfig: SoundConfig
An optional config object containing default sound settings.
ReadonlycurrentCurrently playing marker. 'null' if whole sound is playing.
ReadonlydurationA value representing the duration, in seconds. It could be total sound duration or a marker duration.
ReadonlyisFlag indicating if sound is currently paused.
ReadonlyisFlag indicating if sound is currently playing.
ReadonlykeyAsset key for the sound.
Local reference to the sound manager.
ReadonlymarkersObject containing markers definitions.
Flag indicating if destroy method was called on this sound.
ReadonlytotalThe total duration of the sound in seconds.
ReadonlytotalA property that holds the value of sound's actual playback rate, after its rate and detune values have been combined with global rate and detune values.
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.
Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback.
Marker object.
Whether the marker was added successfully.
Method used internally for applying config values to some of the sound properties.
Method used internally to calculate total playback rate of the sound.
Destroys this sound and all associated events and marks it for removal from the sound manager.
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
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.
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.
Pauses the sound. This only works if the sound is currently playing.
You can inspect the isPlaying and isPaused properties to check the state.undefined
Whether the sound was paused successfully.
Play this sound, or a marked section of it.
It always plays the sound from the start. If you want to start playback from a specific time you can set 'seek' setting of the config object, provided to this call, to that value.
OptionalmarkerName: string | SoundConfig
If you want to play a marker then provide the marker name here. Alternatively, this parameter can be a SoundConfig object. Default ''.
Optionalconfig: SoundConfig
Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound.
Whether the sound started playing successfully.
Remove all listeners, or those of the specified event.
Optionalevent: string | symbol
The event name.
this.
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.
Removes a marker from the sound.
The name of the marker to remove.
Removed marker object or 'null' if there was no marker with provided name.
Method used internally for resetting values of some of the config properties.
Resumes the sound. This only works if the sound is paused and not already playing.
You can inspect the isPlaying and isPaused properties to check the state.undefined
Whether the sound was resumed successfully.
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.
Stop playing this sound.undefined
Whether the sound was stopped successfully.
Update method called automatically by sound manager on every game step.
The current timestamp as generated by the Request Animation Frame or SetTimeout.
The delta time elapsed since the last frame.
Updates a previously added marker with new values from the provided marker object.
Marker object with updated values.
Whether the marker was updated successfully.
Base class containing all the shared state and behavior of a sound object, independent of the audio implementation (Web Audio or HTML5 Audio). Manages playback state (play, pause, stop, seek), looping, volume, rate, detune, markers for playing sub-sections of audio, and event emission for playback lifecycle changes.