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, : string)
ParamTypeDescription
clientClient

The Fluxer client instance

channelVoiceChannel

The voice channel to connect to

_userIdstring

The user ID (reserved for future use)

Properties

activeSpeakers: Set<string> (readonly)
audioSource: AudioSource | null
audioTrack: LocalAudioTrack | null
channel: VoiceChannel (readonly)
client: Client (readonly)
currentStream: { destroy?: () => void } | null
currentVideoStream: { destroy?: () => void } | null
guildId: string (readonly)
lastServerEndpoint: string | null
lastServerToken: string | null
participantTrackSids: Map<string, string> (readonly)
playing: boolean (readonly)

Whether audio is currently playing.

playingVideo: boolean (readonly)

Whether a video track is currently playing in the voice channel.

receiveSubscriptions: Map<string, LiveKitReceiveSubscription> (readonly)
requestedSubscriptions: Map<string, boolean> (readonly)
room: Room | null
videoSource: VideoSource | null
videoTrack: LocalVideoTrack | null

Methods

audioDebug(msg: string, data?: object): void
ParamTypeDescription
msgstring
data?object
clearReceiveSubscriptions(): void

Connect to the LiveKit room using voice server and state from the gateway. Called internally by VoiceManager; typically not used directly.

ParamTypeDescription
serverGatewayVoiceServerUpdateDispatchData

Voice server update data (endpoint, token)

_stateGatewayVoiceStateUpdateDispatchData

Voice state update data (session, channel)

debug(msg: string, data?: object | string): void
ParamTypeDescription
msgstring
data?object | string
destroy(): void

Disconnect from the room and remove all event listeners.

disconnect(): void

Disconnect from the LiveKit room and stop all playback.

emitDisconnect(source: string): void
ParamTypeDescription
sourcestring
getParticipantId(participant: RemoteParticipant): string
ParamTypeDescription
participantRemoteParticipant
getVolume(): number

Get current volume (0-200).

isAudioTrack(track: RemoteTrack): boolean
ParamTypeDescription
trackRemoteTrack
isConnected(): boolean

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

isSameServer(endpoint: string | null, token: string): boolean

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

ParamTypeDescription
endpointstring | null

Voice server endpoint from the gateway

tokenstring

Voice server token

play(urlOrStream: string | NodeJS.ReadableStream): Promise<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.

ParamTypeDescription
urlOrStreamstring | NodeJS.ReadableStream

WebM/Opus HTTP(S) URL, `file://` URL, filesystem path, or ReadableStream

playOpus(: NodeJS.ReadableStream): void
ParamTypeDescription
_streamNodeJS.ReadableStream
playVideo(urlOrBuffer: string | ArrayBuffer | Uint8Array, options?: VideoPlayOptions): Promise<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.

ParamTypeDescription
urlOrBufferstring | ArrayBuffer | Uint8Array

Video source: HTTP(S) URL to an MP4 file, or raw ArrayBuffer/Uint8Array of MP4 data

options?VideoPlayOptions

Optional playback options (see VideoPlayOptions)

playVideoFFmpeg(url: string, options?: VideoPlayOptions): Promise<void>

FFmpeg-based video playback. Bypasses node-webcodecs to avoid libc++abi crashes on macOS. Requires ffmpeg and ffprobe in PATH. URL input only.

ParamTypeDescription
urlstring
options?VideoPlayOptions
setVolume(volumePercent: number): void

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

ParamTypeDescription
volumePercentnumber
stop(): void

Stop playback and clear both audio and video tracks.

stopVideo(): void
subscribeParticipantAudio(participantId: string, options: { autoResubscribe?: boolean; }): LiveKitReceiveSubscription
ParamTypeDescription
participantIdstring
options{ autoResubscribe?: boolean; }
subscribeParticipantTrack(participant: RemoteParticipant, track: RemoteTrack, options: { autoSubscribe?: boolean; }): void
ParamTypeDescription
participantRemoteParticipant
trackRemoteTrack
options{ autoSubscribe?: boolean; }