purple-pencil-19674
10/28/2025, 5:33 AMtall-airline-16756
10/28/2025, 5:33 AMtall-airline-16756
10/28/2025, 5:34 AMroomService.moveParticipant method in LiveKit works. When you move a participant from one room to another, their tracks are unpublished from the original room, and they won’t be automatically republished in the new room. This is actually how it’s designed to work.
To make sure the participant’s tracks show up in the new room, you’ll just need to manually handle republishing the tracks from your client-side application once the participant has joined the destination room. If you need any help with that, I’m here for you!
Sources: roomclient.go | pkg/rtc/participant.go | Connecting to LiveKit | LiveKit Docs | packages/livekit-server-sdk/src/RoomServiceClient.ts | livekit/livekit_room.twirp.gopurple-pencil-19674
10/28/2025, 5:35 AMtall-airline-16756
10/28/2025, 5:36 AMMoveParticipant API to move participants between different rooms. This approach helps keep groups nicely separated, manages room lifecycles automatically, and handles signaling smoothly—so participants get the natural join and leave events in their respective rooms.
While you might consider using subscription controls like UpdateSubscriptions to manage who hears which tracks, this method isn’t really designed for breakout rooms. It can make things more complicated and doesn’t offer the same clear separation or experience as using distinct rooms.
So, for a clean and effective way to create breakout sessions, using the MoveParticipant API is definitely the way to go.
Sources: Subscribing to tracks | LiveKit Docs | Rooms, participants, and tracks | LiveKit Docs | livekit/livekit_rtc.pb.go | livekit-api/livekit/api/room_service.pypurple-pencil-19674
10/28/2025, 5:37 AMtall-airline-16756
10/28/2025, 5:37 AMempty_timeout), the room will close automatically.
• Departure Timeout: Once the last participant leaves, the room stays open for a bit longer (configured with departure_timeout). If no one comes back during this time, the room closes.
If you’re looking to have a session that strictly lasts for a set amount of time—like 60 minutes from when the room is created—you can use the DeleteRoom API to close the room and disconnect everyone manually. You might find it helpful to set up a timer or a cron job in your app to handle this smoothly.
Sources: pkg/rtc/room.go | Connecting to LiveKit | LiveKit Docs | Managing rooms | LiveKit Docs | protobufs/livekit_room.protopurple-pencil-19674
10/28/2025, 6:22 AMtall-airline-16756
10/28/2025, 6:23 AMRoomEvent.Moved event:
`import { Room, RoomEvent, ConnectionState } from 'livekit-client';
class RoomSwitchManager {
private currentRoom: Room | null = null;
async connectToRoom(url: string, token: string): Promise<void> {
const room = new Room();
this.setupRoomEventListeners(room);
await room.connect(url, token);
this.currentRoom = room;
console.log(`Connected to room: ${room.name}`);
}
private setupRoomEventListeners(room: Room): void {
room.on(RoomEvent.Moved, this.handleRoomMoved.bind(this));
room.on(RoomEvent.ConnectionStateChanged, (state: ConnectionState) => {
console.log(`Connection state changed: ${state}`);
});
}
private async handleRoomMoved(newRoomName: string): Promise<void> {
console.log(`Moved to new room: ${newRoomName}`);
// This is a great spot to update your UI, clear any previous state, or notify other parts of your application
}
async disconnect(): Promise<void> {
if (this.currentRoom) {
await this.currentRoom.disconnect();
this.currentRoom = null;
}
}
}
// Usage example
const manager = new RoomSwitchManager();
manager.connectToRoom('wss://your-livekit-server', 'your-access-token');</code></pre><br/><p>This template thoughtfully includes:</p><ul><li>Event listener setup for <code>RoomEvent.Moved</code> to smoothly handle room switching.</li><li>Connection state management along with hooks for room-specific logic.</li><li>Methods designed to help you update the UI or clear state right after switching rooms.</li></ul><br/><p>If you have any questions or would like me to walk you through adding more features, just let me know—I’m here to help!</p>` Sources: src/room/Room.tspurple-pencil-19674
10/28/2025, 6:24 AMtall-airline-16756
10/28/2025, 6:24 AMMoveParticipant API, the LiveKit SDK takes care of the reconnection process for the participant automatically. This means the participant is smoothly moved to the new room without any need for manual reconnection on the client side.
Of course, you can still listen for the RoomEvent.Moved event to update your application logic, like refreshing the UI or clearing any room-specific data, but rest assured, no manual reconnection is necessary. If you have any questions about this, feel free to ask—I'm here to help!purple-pencil-19674
10/28/2025, 6:25 AMtall-airline-16756
10/28/2025, 6:25 AMMoveParticipant, as the camera and audio states (like whether they're enabled or disabled, and their settings) don’t carry over automatically because the participant’s tracks get unpublished during the move. But don’t worry, you can manage this smoothly by handling these states manually on your side:
1. Before you move, it’s a good idea to save the current camera and microphone states using localParticipant.isCameraEnabled and localParticipant.isMicrophoneEnabled.
2. Once the move is done, simply re-enable the camera and microphone in the new room with setCameraEnabled(true) and setMicrophoneEnabled(true).
3. If you had specific track settings like resolution or frame rate, just reapply those using setTrackSettings or by republishing tracks with the settings you want.
This way, you can make sure your participant’s media state stays consistent and everything feels seamless across rooms. If you need any help with this, I’m here for you!
Sources: livekit/livekit_room.pb.go | pkg/rtc/participant.go | React Core and Components | roomclient.gopurple-pencil-19674
10/28/2025, 6:26 AMYou have been moved to room: ${name})
try {
// Wait a bit for the room switch to complete
await new Promise(resolve => setTimeout(resolve, 500))
// Get current track states
const videoPublication = Array.from(localParticipant.videoTrackPublications.values())[0]
const audioPublication = Array.from(localParticipant.audioTrackPublications.values())[0]
const videoTrack = videoPublication?.track as LocalVideoTrack | undefined
const audioTrack = audioPublication?.track as LocalAudioTrack | undefined
const wasVideoEnabled = videoTrack && !videoTrack.isMuted
const wasAudioEnabled = audioTrack && !audioTrack.isMuted
console.log('Track states before republish:', { wasVideoEnabled, wasAudioEnabled })
// Method 1: Unpublish and republish
const republishPromises: Promise<any>[] = []
if (videoTrack) {
console.log('Unpublishing and republishing video track')
republishPromises.push(
localParticipant.unpublishTrack(videoTrack)
.then(() => new Promise(resolve => setTimeout(resolve, 200)))
.then(() => localParticipant.publishTrack(videoTrack, {
name: 'camera',
simulcast: true,
}))
.then(() => {
if (!wasVideoEnabled) {
return videoTrack.mute()
}
})
)
}
if (audioTrack) {
console.log('Unpublishing and republishing audio track')
republishPromises.push(
localParticipant.unpublishTrack(audioTrack)
.then(() => new Promise(resolve => setTimeout(resolve, 200)))
.then(() => localParticipant.publishTrack(audioTrack, {
name: 'microphone',
}))
.then(() => {
if (!wasAudioEnabled) {
return audioTrack.mute()
}
})
)
}
await Promise.all(republishPromises)
console.log('All tracks republished successfully after room move')
} catch (err) {
console.error('[MeetingUI] failed to republish tracks after move', err)
} finally {
setTimeout(() => {
isRepublishingRef.current = false
}, 1000)
}
}
room.on(RoomEvent.Moved, handleRoomMoved)
return () => {
room.off(RoomEvent.Moved, handleRoomMoved)
}
}, [room, localParticipant])
Why is this not working, my video appears as blank to other participantstall-airline-16756
10/28/2025, 6:27 AMpublishTrack, make sure to explicitly trigger negotiation by using localParticipant.engine.negotiate(). This step is important to keep everything in sync.
2. Use Built-in Methods: Instead of manually unpublishing and republishing tracks, try using republishAllTracks(). This method handles the process smoothly and keeps everything synchronized.
3. Ensure Track Validity: Before republishing, double-check that the track isn't muted and that its state is live (for example, track.mediaStreamTrack.readyState === 'live').
4. Retain Video Renderer: Make sure the video rendering component stays attached during the republish cycle. If needed, reattach it explicitly to avoid losing the video display.
5. Handle Reconnection Events: Keep an eye on Reconnected and LocalTrackPublished events. Listening to these helps confirm that media is flowing properly after any reconnection.
Following these steps should help ensure your video and audio tracks are republished correctly and visible to everyone involved. If you need any further assistance, please don't hesitate to reach out—I'm here to help!
Sources: livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Local... | Connecting to LiveKit | LiveKit Docs | src/room/participant/LocalParticipant.ts | localparticipant.go | livekit/src/room/mod.rspurple-pencil-19674
10/28/2025, 7:41 AMtall-airline-16756
10/28/2025, 7:42 AMlocalParticipant.engine.negotiate(). This helps signal the new track to everyone else in the room.
2. Handle Full Reconnection: If you experience a full reconnection, patiently wait for the Reconnected event, then ensure all your tracks are republished using republishAllTracks(). This keeps everything in sync.
3. Check Track State: It’s a good idea to verify that your track isn’t muted and that its state is live before republishing. For instance, check if track.mediaStreamTrack.readyState === 'live' to confirm.
4. Use Built-in Methods: Whenever possible, try to use republishAllTracks() instead of manually unpublishing and republishing tracks. This can help avoid any tricky synchronization issues.
5. Retry Logic: Sometimes, the first republish attempt might not go through. Implementing retry logic with backoff can be really helpful. If needed, you might also stop and recreate the track before trying again.
I hope these steps make things clearer and help get your video visible to everyone after switching rooms. If you’d like, I’m here to walk you through specific code examples or any other questions you have!
Sources: CHANGELOG.md | Connecting to LiveKit | LiveKit Docs | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Local...