I integrated livekit nextjs, but it freezes when I...
# ask-ai
b
I integrated livekit nextjs, but it freezes when I open the camera.
t
Thanks for reaching out, Sinan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to help you out! Could you please share your current
LiveKitRoom
configuration? A few details that would be really helpful: • Are you starting with
video={true}
or
video={false}
? • Are you using any track processors, like background blur? • When exactly does the freeze happen? For example, is it during the permission request, right after permission is granted, or once the video starts? • Have you noticed any errors or logs, such as the
onMediaDeviceFailure
callback being triggered? • Which browser and device are you using? With this info, I’ll be better equipped to understand what’s going on and help you find the best solution. Looking forward to your reply! Sources: packages/react/CHANGELOG.md | agent-console/app/room/page.tsx | avatars/tavus/voice-assistant-frontend/app/page.tsx | android/src/main/java/com/oney/WebRTCModule/CameraEventsHandler.java
b
this code ? async connect(roomName: string, participantName: string, token: string) { try { console.log('🎯 LiveKit bağlanıyor:', { roomName, participantName, url: this.config.url }); this.room = new Room({ adaptiveStream: true, dynacast: true, autoSubscribe: true, audioCaptureDefaults: { autoGainControl: true, echoCancellation: true, noiseSuppression: true, }, videoCaptureDefaults: { resolution: { width: 1280, height: 720, frameRate: 30 } }, }); this.setupRoomEvents(); await this.room.connect(this.config.url, token, { autoSubscribe: true, }); this.isConnected = true; console.log('✅ LiveKit bağlantısı kuruldu'); this.handleExistingParticipants(); await this.room.localParticipant.setMicrophoneEnabled(true); console.log('🎤 Mikrofon etkinleştirildi'); this.onConnected(roomName); } catch (error) { console.error('❌ LiveKit bağlantı hatası:', error); this.onError(
LiveKit bağlantı hatası: ${error}
); throw error; } }
t
Thank you so much for sharing your code with me! From what you've described, the freezing issue might be linked to certain settings or device limitations. Let’s walk through some steps together to troubleshoot and hopefully get this resolved: • Error Handling: It’s a great idea to add error handling for media device issues using
RoomEvent.MediaDevicesError
. This can really help us figure out if the problem is related to device permissions or availability. • Video Defaults: You might want to try starting with a lower resolution in
videoCaptureDefaults
, like
VideoPresets.h540
. This can ease the load on your device and might prevent freezing. • Codec Configuration: If you’re currently using VP9, switching to VP8 could improve compatibility. You can update your configuration with
publishDefaults: { videoCodec: 'vp8' }
. • Device Management: Double-check that the correct video device is selected and isn’t being used by another app. Using
Room.getLocalDevices('videoinput')
can help you list all available devices. • Timing: It would be helpful to know when the freezing happens—does it occur right when you connect, after enabling the camera, or during certain actions? This info can really help us narrow down the cause. Also, could you take a quick look at your browser console for any
MediaDevicesError
events or WebRTC warnings? Feel free to reach out if you’d like me to guide you through these steps or if you have any questions. I’m here to help! Sources: CHANGELOG.md | app/rooms/[roomName]/PageClientImpl.tsx | React Core and Components | Configuring the Client SDK for Optimal Video Quality