Members
context :AudioContext
The underlying AudioContext.
Type:
- AudioContext
gain :AudioParam
The gain value. When changed, this is almost instantaneous but a small time constant is applied to minimise clicks.
Type:
- AudioParam
(readonly) inputNode
The input for the audio manager. This is where all nodes should connect if they want to connect to the destination of the underlying destination.
Methods
addAudioSfx(definition) → {Promise}
Create an AudioSfxPlayer. It is stored in a map of sound effects. It is only stored once ready to play, so it may not be available in the map immediately. If the definition includes a loop property, it is set to false as sound effects are not allowed to loop.
Parameters:
| Name | Type | Description |
|---|---|---|
definition |
module:hcje/audio~AudioDefinition | module:hcje/audio~SynthAudioDefinition | Details of the sound to add. |
Returns:
Fulfils to true on success.
- Type
- Promise
playAudioSfx(title)
Play audio effect. The title is used as a lookup into the map of existing sound effects.
Parameters:
| Name | Type | Description |
|---|---|---|
title |
string | Title of the sound effect. |
setMusic(definition) → {Promise}
Set the background music. The background music will automatically start. Any stop or start commands to the player are cached, so that if it takes a long time to load, the final playing state will still reflect the last command received.
Parameters:
| Name | Type | Description |
|---|---|---|
definition |
module:hcje/audio~AudioDefinition | module:hcje/audio~SynthAudioDefinition | Details of the music to add. |
Returns:
Fulfils to true on success.
- Type
- Promise
startMusic()
Start playing the background music.
stopMusic()
Stop background music.