Documentation Index Fetch the complete documentation index at: https://docs.streampixel.io/llms.txt
Use this file to discover all available pages before exploring further.
Voice and text chat powered by LiveKit.
Constructor
import { StreamPixelVoiceChat } from 'streampixelsdk' ;
const voiceChat = new StreamPixelVoiceChat ( roomName , userName , voiceChat , avatar , micStart );
Parameter Type Description roomNamestringRoom identifier. Users in the same room can communicate. userNamestringDisplay name for this user voiceChatbooleantrue for voice chat, false for text-onlyavatarstringURL to user’s avatar image micStartbooleanStart with microphone enabled (only if voiceChat is true)
Methods
async join()
Join the voice chat room. Fetches a token, connects to the LiveKit server, subscribes to audio, and enables the mic if configured.
async leave()
Disconnect from the room.
async toggleMic()
Toggle the local microphone on or off.
await voiceChat . toggleMic ();
sendMessage(text)
Send a text message to all participants in the room.
Parameter Type Description textstringMessage content
voiceChat . sendMessage ( 'Hello!' );
async muteAllRemote()
Mute all remote participants locally (you stop hearing them).
await voiceChat . muteAllRemote ();
async unmuteAllRemote()
Unmute all remote participants locally.
await voiceChat . unmuteAllRemote ();
async muteSelected(identity)
Mute a specific participant locally.
Parameter Type Description identitystringThe participant’s identity
await voiceChat . muteSelected ( 'user123' );
async unmuteSelected(identity)
Unmute a specific participant locally.
Parameter Type Description identitystringThe participant’s identity
await voiceChat . unmuteSelected ( 'user123' );
All mute/unmute operations (muteAllRemote, unmuteAllRemote, muteSelected, unmuteSelected) are local only. They control what you hear, not what other participants hear. Other users are not affected.
onMessage(callback)
Register a callback for incoming messages (including your own).
voiceChat . onMessage (( msg ) => {
console . log ( msg . from , msg . text , msg . avatar );
});
Callback data:
Property Type Description fromstringSender’s identity ("You" for local messages) textstringMessage content avatarstringSender’s avatar URL
onParticipantUpdate(callback)
Register a callback for participant list changes and speaking state updates.
voiceChat . onParticipantUpdate (( data ) => {
console . log ( data . localParticipant );
console . log ( data . remoteParticipants );
});
Callback data:
{
localParticipant : {
id : string , // User identity
avatar : string , // Avatar URL
speaking : boolean // Currently speaking
},
remoteParticipants : [
{
id: string ,
avatar: string ,
speaking: boolean
}
]
}
Next steps
Voice and text chat guide End-to-end guide with full usage examples.
SFU streaming Pair voice chat with one-to-many SFU sessions.