Create a new SoundSlot.
The Component that created this slot.
Optional
name: string = 'Untitled'The name of the slot. Defaults to 'Untitled'.
Optional
options: { Settings for the slot.
The asset id of the audio asset that is going to be played by this slot.
If true, the slot will start playing as soon as its audio asset is loaded.
The duration of the sound that the slot will play starting from startTime.
If true, the sound will restart when it reaches the end.
If true, then sounds played from slot will be played independently of each other. Otherwise the slot will first stop the current sound before starting the new one.
The relative pitch, default of 1, plays at normal pitch.
The start time from which the sound will start playing.
The playback volume, between 0 and 1.
An array that contains all the SoundInstances currently being played by the slot.
The name of the slot.
Gets the asset id.
Sets the asset id.
Gets whether the slot will begin playing as soon as it is loaded.
Sets whether the slot will begin playing as soon as it is loaded.
Gets the duration of the sound that the slot will play starting from startTime.
Sets the duration of the sound that the slot will play starting from startTime.
Gets whether the asset of the slot is loaded.
Gets whether the slot is currently paused.
Gets whether the slot is currently playing.
Gets whether the slot is currently stopped.
Gets whether the slot will restart when it finishes playing.
Sets whether the slot will restart when it finishes playing.
Gets whether the sounds played from this slot will be played independently of each other.
Sets whether the sounds played from this slot will be played independently of each other. Otherwise, the slot will first stop the current sound before starting the new one.
Gets the pitch modifier to play the sound with.
Sets the pitch modifier to play the sound with. Must be larger than 0.01.
Gets the start time from which the sound will start playing.
Sets the start time from which the sound will start playing.
Gets the volume modifier to play the sound with.
Sets the volume modifier to play the sound with. In range 0-1.
Clears any external nodes set by SoundSlot#setExternalNodes.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Gets an array that contains the two external nodes set by SoundSlot#setExternalNodes.
An array of 2 elements that contains the first and last nodes set by SoundSlot#setExternalNodes.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Pauses all sound instances. To continue playback call SoundSlot#resume.
True if the sound instances paused successfully, false otherwise.
Plays a sound. If SoundSlot#overlap is true the new sound instance will be played independently of any other instances already playing. Otherwise existing sound instances will stop before playing the new sound.
The new sound instance.
Connect external Web Audio API nodes. Any sound played by this slot will automatically attach the specified nodes to the source that plays the sound. You need to pass the first node of the node graph that you created externally and the last node of that graph. The first node will be connected to the audio source and the last node will be connected to the destination of the AudioContext (e.g. speakers).
Static
EVENT_Static
EVENT_Fired when a SoundInstance is paused on a slot. The handler is passed the sound instance that is paused.
Static
EVENT_Fired when a SoundInstance starts playing on a slot. The handler is passed the sound instance that started playing.
Static
EVENT_Fired when a SoundInstance is resumed on a slot. The handler is passed the sound instance that is resumed.
Static
EVENT_Fired when a SoundInstance is stopped on a slot. The handler is passed the sound instance that is stopped.
The SoundSlot controls playback of an audio asset.