salmon-lighter-12882
08/14/2025, 11:57 PMtall-airline-16756
08/14/2025, 11:57 PMtall-airline-16756
08/14/2025, 11:58 PMyarn update livekit-client
.
2. Try explicitly stopping and restarting your audio tracks during reconnect. Here's an example:
async function reconnect() {
try {
// Stop existing tracks if they exist
const tracks = await room.localParticipant.getTracks();
for (const track of tracks) {
await track.stop();
}
// Then reconnect
await room.reconnect();
// Restart tracks after reconnect
await room.localParticipant.setMicrophoneEnabled(true);
} catch (error) {
console.error("Reconnect error:", error);
}
}
1. Also, it’s a good idea to handle permissions explicitly before accessing the microphone:
async function checkPermissions() {
try {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
// Stop the stream so the mic indicator doesn’t stay on unnecessarily
stream.getTracks().forEach(t => t.stop());
} catch (error) {
if (error.name === "NotAllowedError") {
alert("Microphone permission is needed. Please enable microphone access in your browser settings.");
}
}
}
One last tip: double-check that your browser allows microphone access for your site, and maybe try testing in different browsers to narrow down the cause. If you run into any more bumps or want a hand with this, just let me know—I’m here to help!
Sources: src/room/Room.ts | quickstart/src/userfriendlyerror.js