constaudio:object
Defined in: sdk/js/src/audio.ts:29
The bot’s audio output stream. Errors throw ZaunError.
Type Declaration
Section titled “Type Declaration”bufferedMs()
Section titled “bufferedMs()”bufferedMs():
number
The audio written and not yet played, in ms (0 without a stream).
Returns
Section titled “Returns”number
clear()
Section titled “clear()”clear():
void
Drops everything buffered at once; the stream stays open.
Returns
Section titled “Returns”void
close()
Section titled “close()”close(
drain?):void
Closes the stream, after the buffer has played (drain, the default) or at once.
Parameters
Section titled “Parameters”drain?
Section titled “drain?”boolean = true
Returns
Section titled “Returns”void
open()
Section titled “open()”open(
options):void
Opens the stream, pausing the player. CONFLICT when the bot is in no voice channel or a
stream is open; UNSUPPORTED for a format the host cannot take (PCM without an encoder).
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
writeOpus()
Section titled “writeOpus()”writeOpus(
packets):number
Opus packets (2.5–120 ms each, ≤ 1000 bytes); returns the ms buffered (BUSY past 3 s).
Parameters
Section titled “Parameters”packets
Section titled “packets”Uint8Array<ArrayBufferLike>[]
Returns
Section titled “Returns”number
writePcm()
Section titled “writePcm()”writePcm(
samples):number
Interleaved samples, any count; returns the ms buffered (BUSY past 3 s).
Parameters
Section titled “Parameters”samples
Section titled “samples”Int16Array
Returns
Section titled “Returns”number