Members
true to start playing immediate after load.
- Default Value:
- false
context IMediaContext
Instance of the media context.
Get the duration of the audio in seconds.
filters filters.Filter[]
Set the filters. Only supported with WebAudio.
instances IMediaInstance[]
Gets the list of instances that are currently being played of this sound.
true
if the buffer is loaded.
- Default Value:
- false
If the current sound is playable (loaded).
true
if the sound is currently being played.
- Default Value:
- false
Gets and sets the looping.
media IMedia
The audio source
Gets and sets the muted flag.
options Options readonly
The constructor options.
Stops all the instances of this sound from playing.
true
to immediately start preloading.
- Default Value:
- false
true
to disallow playing multiple layered instances at once.
- Default Value:
- false
The playback rate.
Get the map of sprites.
The file source to load.
Gets and sets the volume.
Methods
Sound.from (source) Sound static
Create a new sound instance from source.
Name | Type | Description |
---|---|---|
source |
string | string[] | Options | ArrayBuffer | HTMLAudioElement | AudioBuffer |
Either the path or url to the source file. or the object of options to use. |
Returns:
Type | Description |
---|---|
Sound | Created sound instance. |
addSprites (alias, data) SoundSprite
Add a sound sprite, which is a saved instance of a longer sound. Similar to an image spritesheet.
Name | Type | Description |
---|---|---|
alias |
string |
The unique name of the sound sprite. |
data |
SoundSpriteData |
Either completed function or play options. |
Returns:
Type | Description |
---|---|
SoundSprite |
Convenience method to add more than one sprite add a time.
Name | Type | Description |
---|---|---|
data |
SoundSpriteDataMap |
Map of sounds to add where the key is the alias, and the data are configuration options. |
Returns:
Type | Description |
---|---|
SoundSprites | The map of sound sprites added. |
autoPlayStart () IMediaInstance
Auto play the first instance.
Returns:
Type | Description |
---|---|
IMediaInstance |
Destructor, safer to use SoundLibrary.remove(alias)
to remove this sound.
Stops all the instances of this sound from playing.
Returns:
Type | Description |
---|---|
this |
play (alias, callback) IMediaInstance | IMediaInstance<Promise>
Play a sound sprite, which is a saved instance of a longer sound. Similar to an image spritesheet.
Name | Type | Attributes | Description |
---|---|---|---|
alias |
string | PlayOptions | CompleteCallback |
<optional> |
The unique name of the sound sprite. |
callback |
Function |
<optional> |
Callback when completed. |
Returns:
Type | Description |
---|---|
IMediaInstance | IMediaInstance<Promise> | The sound instance, this cannot be reused after it is done playing. Returns a Promise if the sound has not yet loaded. |
play (source, callback) IMediaInstance | IMediaInstance<Promise>
Plays the sound.
Name | Type | Attributes | Description |
---|---|---|---|
source |
Function | PlayOptions |
<optional> |
Either completed function or play options. |
callback |
Function |
<optional> |
Callback when completed. |
Returns:
Type | Description |
---|---|
IMediaInstance | IMediaInstance<Promise> | The sound instance, this cannot be reused after it is done playing. Returns a Promise if the sound has not yet loaded. |
Internal only, speed, loop, volume change occured.
Handle changes in paused state. Internal only.
removeSprites (alias) Sound
Remove a sound sprite.
Name | Type | Attributes | Description |
---|---|---|---|
alias |
string |
<optional> |
The unique name of the sound sprite, if alias is omitted, removes all sprites. |
Returns:
Type | Description |
---|---|
Sound |
Resuming all the instances of this sound from playing
Returns:
Type | Description |
---|---|
this |
Stops all the instances of this sound from playing.
Returns:
Type | Description |
---|---|
this |