Class

LiveKitRtcConnection

Voice connection using LiveKit RTC. Used when Fluxer routes voice to LiveKit. Supports both audio playback (play) and video streaming (playVideo) to voice channels. Video uses node-webcodecs for decoding (no ffmpeg subprocess). Audio uses prism-media WebM demuxer.

Extends EventEmitter

Constructor

new LiveKitRtcConnection(client: Client, channel: VoiceChannel, _userId: string)
client
ClientThe Fluxer client instance
channel
VoiceChannelThe voice channel to connect to
_userId
stringThe user ID (reserved for future use)

Properties

NameTypeDescription
channelread-onlyVoiceChannel
clientread-onlyClient
guildIdread-onlystring
playingread-onlybooleanWhether audio is currently playing.
playingVideoread-onlybooleanWhether a video track is currently playing in the voice channel.

Methods

.destroy()

void

Disconnect from the room and remove all event listeners.

liveKitRtcConnection.destroy();

.disconnect()

void

Disconnect from the LiveKit room and stop all playback.

liveKitRtcConnection.disconnect();

.getVolume()

number

Get current volume (0-200).

liveKitRtcConnection.getVolume();

.isConnected()

boolean

Returns true if the LiveKit room is connected and not destroyed.

liveKitRtcConnection.isConnected();

.isSameServer(endpoint, token)

endpoint: string | null, token: stringboolean

Returns true if we're already connected to the given server (skip migration).

endpoint
string | nullVoice server endpoint from the gateway
token
stringVoice server token
liveKitRtcConnection.isSameServer(endpoint, token);

.play(urlOrStream)

urlOrStream: string | NodeJS.ReadableStreamPromise<void>

Play audio from a WebM/Opus source. Publishes to the LiveKit room as an audio track. When urlOrStream is a string: http(s):// is fetched; file:// or any other string is read from the local filesystem (path). Otherwise pass a Node.js ReadableStream.

urlOrStream
string | NodeJS.ReadableStreamWebM/Opus HTTP(S) URL, file:// URL, filesystem path, or ReadableStream
await liveKitRtcConnection.play(urlOrStream);

.playOpus(_stream)

_stream: NodeJS.ReadableStreamvoid

liveKitRtcConnection.playOpus(_stream);

.playVideo(urlOrBuffer, options?)

urlOrBuffer: string | ArrayBuffer | Uint8Array, options?: VideoPlayOptionsPromise<void>

Play video from an MP4 URL or buffer. Streams decoded frames to the LiveKit room as a video track. Uses node-webcodecs for decoding (no ffmpeg). Supports H.264 (avc1) and H.265 (hvc1/hev1) codecs.

urlOrBuffer
string | ArrayBuffer | Uint8ArrayVideo source: HTTP(S) URL to an MP4 file, or raw ArrayBuffer/Uint8Array of MP4 data
options?
VideoPlayOptionsOptional playback options (see VideoPlayOptions)
const conn = await voiceManager.join(channel);
if (conn instanceof LiveKitRtcConnection && conn.isConnected()) {
  await conn.playVideo('https://example.com/video.mp4', { source: 'camera' });
}

.setVolume(volumePercent)

volumePercent: numbervoid

Set playback volume (0-200, 100 = normal). Affects current and future playback.

liveKitRtcConnection.setVolume(volumePercent);

.stop()

void

Stop playback and clear both audio and video tracks.

liveKitRtcConnection.stop();