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 Array<filters.Filter>
Set the filters. Only supported with WebAudio.
instances Array<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.
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 (options) Sound static
Create a new sound instance from source.
Name | Type | Description |
---|---|---|
options |
ArrayBuffer | String | Options | HTMLAudioElement |
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 |
object |
Either completed function or play options. |
data.start |
number |
Time when to play the sound in seconds. |
data.end |
number |
Time to end playing in seconds. |
data.speed |
number |
Override default speed, default to the Sound's speed setting. |
Returns:
Type | Description |
---|---|
SoundSprite | Sound sprite result. |
Convenience method to add more than one sprite add a time.
Name | Type | Description |
---|---|---|
data |
Object |
Map of sounds to add where the key is the alias, and the data are configuration options, see Sound#addSprite for info on data. |
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 | Instance of this sound. |
play (alias, callback) 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 | Promise | The sound instance, this cannot be reused after it is done playing. Returns a Promise if the sound has not yet loaded. |
play (options) IMediaInstance | Promise
Plays the sound.
Name | Type | Attributes | Description |
---|---|---|---|
options |
Function | PlayOptions |
<optional> |
Either completed function or play options. |
Returns:
Type | Description |
---|---|
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 | Sound instance for chaining. |
Resuming all the instances of this sound from playing
Returns:
Type | Description |
---|---|
this | Instance of this sound. |
Stops all the instances of this sound from playing.
Returns:
Type | Description |
---|---|
this | Instance of this sound. |