Skip to content

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.

beep(opts?): void

Defined in: packages/threeplay/src/plugins/audio/types.ts:77

A synthesized blip: no assets needed (UI, prototypes, coins).

BeepOpts

void


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.

string

string

Promise<AudioBuffer | null>


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.

string

PlayOpts

AudioPlay


volume(v?): number

Defined in: packages/threeplay/src/plugins/audio/types.ts:79

Master volume 0–1 (get or set).

number

number

readonly audioCtx: 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).