AudioAPI
Defined in: packages/threeplay/src/plugins/audio/types.ts:65
API of the audio plugin (WebAudio). Without WebAudio (Node, old browsers)
everything is inert: play() returns a handle that ends at once.
Sounds keep playing across scenes unless you stop() them (the exception: looping
sounds attached to an object with at stop when that object is destroyed, e.g. by go()).
After quit() no new AudioContext is created.
Methods
Section titled “Methods”beep()
Section titled “beep()”beep(
opts?):void
Defined in: packages/threeplay/src/plugins/audio/types.ts:77
A synthesized blip: no assets needed (UI, prototypes, coins).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
loadSound()
Section titled “loadSound()”loadSound(
name,url):Promise<AudioBuffer|null>
Defined in: packages/threeplay/src/plugins/audio/types.ts:73
Loads and decodes a sound under a name (the first scene waits for it). Resolves null
without audio. Decoding uses an OfflineAudioContext when available, so no real
AudioContext is created before the first play()/beep()/audioCtx access.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<AudioBuffer | null>
play()
Section titled “play()”play(
name,opts?):AudioPlay
Defined in: packages/threeplay/src/plugins/audio/types.ts:75
Plays a loaded sound. Throws (listing the loaded names) for an unknown name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”volume()
Section titled “volume()”volume(
v?):number
Defined in: packages/threeplay/src/plugins/audio/types.ts:79
Master volume 0–1 (get or set).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number
Properties
Section titled “Properties”audioCtx
Section titled “audioCtx”
readonlyaudioCtx:AudioContext|null
Defined in: packages/threeplay/src/plugins/audio/types.ts:67
The shared AudioContext, created on first use (null when unavailable, e.g. in Node).