The global context to use.
This disables auto-pause all playback when the window blurs (WebAudio only).
This is helpful to keep from playing sounds when the user switches tabs.
However, if you're running content within an iframe, this may be undesirable
and you should disable (set to true
) this behavior.
Set the global speed for all sounds. To set per-sound speed see SoundLibrary#speed.
true
if WebAudio is supported on the current browser.
Do not use WebAudio, force the use of legacy. This must be called before loading any files.
Set the global volume for all sounds. To set per-sound volume see SoundLibrary#volume.
Adds multiple sounds at once.
Map of sounds to add, the key is the alias, the value is the
string
, ArrayBuffer
, AudioBuffer
, HTMLAudioElement
or the list of options
(see Options for full options).
Optional
globalOptions: OptionsThe default options for all sounds. if a property is defined, it will use the local property instead.
Instance to the Sound object.
Closes the sound library. This will release/destroy
the AudioContext(s). Can be used safely if you want to
initialize the sound library later. Use init
method.
Get the length of a sound in seconds.
The sound alias reference.
The current duration in seconds.
Checks if a sound by alias exists.
Check for alias.
Optional
assert: booleanWhether enable console.assert.
true if the sound exists.
Re-initialize the sound library, this will
recreate the AudioContext. If there's a hardware-failure
call close
and then init
.
Sound instance
Convenience function to check to see if any sound is playing.
true
if any sound is currently playing.
Mutes all playing sounds.
Instance for chaining.
Pauses any playing sounds.
Instance for chaining.
Plays a sound.
The sound alias reference.
Optional
options: string | CompleteCallback | PlayOptionsThe options or callback when done.
The sound instance, this cannot be reused after it is done playing. Returns a Promise if the sound has not yet loaded.
Removes a sound by alias.
The sound alias reference.
Instance for chaining.
Stops and removes all sounds. They cannot be used after this.
Instance for chaining.
Resumes a sound.
The sound alias reference.
Instance for chaining.
Resumes any sounds.
Instance for chaining.
Get or set the speed for a sound.
The sound alias reference.
Optional
speed: numberOptional current speed to set.
The current speed.
Stops all sounds.
Instance for chaining.
Toggle muted property for all sounds.
true
if all sounds are muted.
Toggle paused property for all sounds.
true
if all sounds are paused.
Unmutes all playing sounds.
Instance for chaining.
Get or set the volume for a sound.
The sound alias reference.
Optional
volume: numberOptional current volume to set.
The current volume.
Manages the playback of sounds. This is the main class for PixiJS Sound. If you're using the browser-based bundled this is
PIXI.sound
. Otherwise, you can do this:Example