new Sound(filepathopt)
The sound for all audio in game.
This add saving/loading and native integration to native Audio.
Parameters:
Name |
Type |
Attributes |
Description |
filepath |
string
|
<optional>
|
The filename of audio without extension |
- Implements:
Members
loadDefer
Audio buffer for Web Audio playback
Properties:
Type |
Attributes |
Description |
Promise.<AudioBuffer>
|
<nullable>
|
|
Methods
fade(options) → {Promise}
Fade the sound, will stop and override existing fade.
Parameters:
Name |
Type |
Description |
options |
Object
|
Properties
Name |
Type |
Description |
fromVolume |
number
|
|
toVolume |
number
|
|
finalVolume |
number
|
|
|
Returns:
- Promise what resolve when the fade ends
-
Type
-
Promise
pause() → {Promise}
Pause the sound
Operation is queued.
Returns:
-
Type
-
Promise
play(filepathopt) → {Promise}
Load (optional) then play the sound.
Operation is queued.
Parameters:
Name |
Type |
Attributes |
Description |
filepath |
string
|
<optional>
|
The audio's filename without extension |
Returns:
-
Type
-
Promise
setFile(filepath) → {Promise}
Load audio.
Operation is queued.
Parameters:
Name |
Type |
Description |
filepath |
string
|
The audio's filename without extension |
Returns:
-
Type
-
Promise
setLoop(loop)
Parameters:
Name |
Type |
Description |
loop |
boolean
|
|
setPan(pan)
Parameters:
Name |
Type |
Description |
pan |
number
|
from -1 to 1, 0 is balanced |
setTime(time)
Seek to middle of the sound
Parameters:
Name |
Type |
Description |
time |
number
|
in milisecond |
setVolume(volume)
Parameters:
Name |
Type |
Description |
volume |
number
|
Volume, from 0 - 1 |
stop() → {Promise}
Stop the sound
Operation is queued.
Returns:
-
Type
-
Promise
stopFade(setFinalVolume) → {Promise}
Stop fade
Parameters:
Name |
Type |
Description |
setFinalVolume |
boolean
|
Should set the sound to it's final volume or just stop fade. |
Returns:
-
Type
-
Promise