Class: SoundManager
Constructors
Constructor
new SoundManager(options: SoundManagerOptions): SoundManager;Parameters
| Parameter | Type |
|---|---|
options | SoundManagerOptions |
Returns
SoundManager
Accessors
muted
Get Signature
get muted(): boolean;Indicates whether the SoundManager is currently muted.
Returns
boolean
ready
Get Signature
get ready(): Promise<void>;A promise that resolves when the SoundManager is fully initialized.
Returns
Promise<void>
unmuted
Get Signature
get unmuted(): boolean;Indicates whether the SoundManager is currently unmuted.
Returns
boolean
volume
Get Signature
get volume(): number;The current volume level of the SoundManager, represented as a number between 0 and 1.
Returns
number
Methods
cleanup()
cleanup(): void;Cleans up the SoundManager by stopping all audio elements and removing internal event listeners.
Returns
void
initialize()
initialize(): Promise<void>;Initializes the SoundManager by loading all audio elements and adding event listeners.
Returns
Promise<void>
mute()
mute(): SoundManager;Mutes all sounds played by the SoundManager.
Returns
SoundManager
The current instance of the SoundManager for easy chaining
off()
off<K>(event: Key<K, SoundManagerEvents>, listener?: Listener<K, SoundManagerEvents>): this;Removes an event listener from the SoundManager.
Type Parameters
| Type Parameter |
|---|
K |
Parameters
| Parameter | Type | Description |
|---|---|---|
event | Key<K, SoundManagerEvents> | The name of the event to unsubscribe from |
listener? | Listener<K, SoundManagerEvents> | The callback to unsubscribe from the event |
Returns
this
The current instance of the SoundManager for easy chaining
on()
on<K>(
event: Key<K, SoundManagerEvents>,
listener: Listener<K, SoundManagerEvents>,
ctx?: any): this;Subscribes an event listener to the SoundManager.
Type Parameters
| Type Parameter |
|---|
K |
Parameters
| Parameter | Type | Description |
|---|---|---|
event | Key<K, SoundManagerEvents> | The event to subscribe the listener to |
listener | Listener<K, SoundManagerEvents> | The callback function to call when the event occurs |
ctx? | any | The this context to apply to the listener when it is called |
Returns
this
The current instance of the SoundManager for easy chaining
once()
once<K>(
event: Key<K, SoundManagerEvents>,
listener: Listener<K, SoundManagerEvents>,
ctx?: any): this;Subscribes an event listener to the SoundManager for a single invocation.
Type Parameters
| Type Parameter |
|---|
K |
Parameters
| Parameter | Type | Description |
|---|---|---|
event | Key<K, SoundManagerEvents> | The event to subscribe the listener to |
listener | Listener<K, SoundManagerEvents> | The callback function to call when the event occurs |
ctx? | any | The this context to apply to the listener when it is called |
Returns
this
The current instance of the SoundManager for easy chaining
play()
play(sound:
| "Fast"
| "Gong"
| "Loud"
| "Ping"
| "Soft"
| "Eager"
| "Gentle"
| "Subtle"
| "Urgent"
| "Classic"
| "General"
| "Sending"
| "Complete"
| "Positive"
| "SoftFast"
| "ShortFast"
| "ShortSlow"
| "FastUrgent"
| "SlowUrgent"
| "UrgentLoud"
| "UrgentSoft"
| "GeneralSoft"
| "PositiveSlow"
| "ImportantFast"): void;Plays the specified notification sound if possible.
Parameters
| Parameter | Type | Description |
|---|---|---|
sound | | "Fast" | "Gong" | "Loud" | "Ping" | "Soft" | "Eager" | "Gentle" | "Subtle" | "Urgent" | "Classic" | "General" | "Sending" | "Complete" | "Positive" | "SoftFast" | "ShortFast" | "ShortSlow" | "FastUrgent" | "SlowUrgent" | "UrgentLoud" | "UrgentSoft" | "GeneralSoft" | "PositiveSlow" | "ImportantFast" | The sound which is desired to be played |
Returns
void
setVolume()
setVolume(volume: number): this;Sets the volume for all sounds played by the SoundManager.
Parameters
| Parameter | Type | Description |
|---|---|---|
volume | number | A double between 0 and 1 which represents the desired volume |
Returns
this
The current instance of the SoundManager for easy chaining
unmute()
unmute(): SoundManager;Restores the volume to its level prior to being muted.
Returns
SoundManager
The current instance of the SoundManager for easy chaining