Class: SoundLoader

SoundLoader

new SoundLoader()

Loads sound files and lets you know when they're all available. An instance of SoundLoader is available as Splat.Game#sounds. This implementation uses the Web Audio API, and if that is not available it automatically falls back to the HTML5 <audio> tag.
Source:

Methods

allLoaded() → {boolean}

Test if all sounds have loaded.
Source:
Returns:
Type
boolean

isMuted() → {boolean}

Test if the volume is currently muted.
Source:
Returns:
True if the volume is currently muted.
Type
boolean

load(name, path)

Load an audio file.
Parameters:
Name Type Description
name string The name you want to use when you SoundLoader#play the sound.
path string The path of the sound file.
Source:

mute()

Silence all sounds. Sounds keep playing, but at zero volume. Call SoundLoader#unmute to restore the previous volume level.
Source:

play(name, loopopt)

Play a sound.
Parameters:
Name Type Attributes Default Description
name string The name given to the sound during SoundLoader#load
loop boolean <optional>
false A flag denoting whether the sound should be looped. To stop a looped sound use SoundLoader#stop.
Source:

setVolume(gain)

Set the volume of all sounds.
Parameters:
Name Type Description
gain number The desired volume level. A number between 0.0 and 1.0, with 0.0 being silent, and 1.0 being maximum volume.
Source:

stop(name)

Stop playing a sound. This currently only stops playing a sound that was looped earlier, and doesn't stop a sound mid-play. Patches welcome.
Parameters:
Name Type Description
name string The name given to the sound during SoundLoader#load
Source:

unmute()

Restore volume to whatever value it was before SoundLoader#mute was called.
Source: