A list of audio sources (clip.wav, clip.mp3, clip.ogg) for this audio clip. This is done for browser compatibility.
Data associated with a loadable
Direct access to the game object event dispatcher.
Get the duration that this audio should play. If unset the total natural playback duration will be used.
Set the duration that this audio should play. If unset the total natural playback duration will be used.
Note: if you seek to a specific point the duration will start from that point, for example
If you have a 10 second clip, seek to 5 seconds, then set the duration to 2, it will play the clip from 5-7 seconds.
Return array of Current AudioInstances playing or being paused
Whether the audio should loop (repeat forever)
Indicates whether the clip should loop when complete
Set the looping flag
Set the playbackRate, default is 1.0 at normal speed. For example 2.0 is double speed, and 0.5 is half speed.
Set the playbackRate, default is 1.0 at normal speed. For example 2.0 is double speed, and 0.5 is half speed.
The volume (between 0 and 1)
The volume (between 0 and 1)
Emits a new event
Name of the event to emit
Data associated with this event
Return the current playback time of the playing track in seconds from the start.
Optionally specify the track to query if multiple are playing at once.
Return the duration of the sound
Returns how many instances of the sound are currently playing
Returns true if the loadable is loaded
Returns if the audio is paused
Whether or not the sound is playing right now
Begins loading the resource and returns a promise to be resolved on completion
Alias for removeEventListener
. If only the eventName is specified
it will remove all handlers registered for that specific event. If the eventName
and the handler instance are specified only that handler will be removed.
Name of the event to listen for
Event handler for the thrown event
Alias for addEventListener
. You can listen for a variety of
events off of the engine; see the events section below for a complete list.
Name of the event to listen for
Event handler for the thrown event
Once listens to an event one time, then unsubscribes from that event
The name of the event to subscribe to once
The handler of the event that will be auto unsubscribed
Stop the sound, and do not rewind
Play the sound, returns a promise that resolves when the sound is done playing An optional volume argument can be passed in to play the sound. Max volume is 1.0
Seek to a position (in seconds) in the audio
Stop the sound if it is currently playing and rewind the track. If the sound is not playing, rewinds the track.
The Sound object allows games built in Excalibur to load audio components, from soundtracks to sound effects. Sound is an Loadable which means it can be passed to a Loader to pre-load before a game or level.