Class: AudioManager

AudioManager(assetLoader, eventManager)

new AudioManager(assetLoader, eventManager)

Parameters:
Name Type Default Description
assetLoader
eventManager null
Source:

Methods

destroy()

Call this when the engine is shutting down.
Source:

pauseAll()

Pauses the AudioContext (suspends all audio).
Source:

playMusic(assetName, loopopt, volumeopt, fadeInDurationopt)

Plays background music. Stops any currently playing music.
Parameters:
Name Type Attributes Default Description
assetName string The name of the pre-loaded audio asset (AudioBuffer).
loop boolean <optional>
true Whether the music should loop.
volume number <optional>
1.0 Volume for this music track (0-1), relative to musicVolume.
fadeInDuration number <optional>
0 Duration in seconds for a fade-in effect.
Source:

playSoundEffect(assetName, volumeopt, playbackRateopt, startTimeopt) → {AudioBufferSourceNode|null}

Plays a sound effect.
Parameters:
Name Type Attributes Default Description
assetName string The name of the pre-loaded audio asset (AudioBuffer).
volume number <optional>
1.0 Volume for this specific sound (0-1), relative to sfxVolume.
playbackRate number <optional>
1.0 Speed of playback.
startTime number <optional>
0 Offset in seconds to start playing from.
Source:
Returns:
The created source node, or null if sound cannot be played.
Type
AudioBufferSourceNode | null

resumeAll()

Resumes the AudioContext (resumes all audio). Needs user interaction to start/resume AudioContext if it was suspended by browser policy.
Source:

stopMusic(fadeOutDurationopt)

Stops the currently playing background music.
Parameters:
Name Type Attributes Default Description
fadeOutDuration number <optional>
0 Duration in seconds for a fade-out effect.
Source: