From bd89c186ded9e437b4bb04dbcc5b9d7350c9726d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pr=C3=A1vics=20P=C3=A9ter?= Date: Thu, 10 Apr 2025 14:57:59 +0200 Subject: [PATCH] fix(call): bug is fixed for me please test it, feat(call): every call starts with turned off camera --- webclient/src/components/Call/Call.vue | 6 +++++- webclient/src/helpers/webrtc.ts | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/webclient/src/components/Call/Call.vue b/webclient/src/components/Call/Call.vue index a4f5446..402074a 100644 --- a/webclient/src/components/Call/Call.vue +++ b/webclient/src/components/Call/Call.vue @@ -21,6 +21,10 @@ onMounted(async () => { watch(localStream, (stream) => { if (localVideo.value && stream) { localVideo.value.srcObject = stream; + const videoTrack = stream.getVideoTracks()[0]; + if (videoTrack) { + videoTrack.enabled = false; + } } }); @@ -46,7 +50,7 @@ onUnmounted(() => { }); const isMicMuted = ref(false); -const isVideoOff = ref(false); +const isVideoOff = ref(true); const isRemoteMuted = ref(false); function toggleMic() { diff --git a/webclient/src/helpers/webrtc.ts b/webclient/src/helpers/webrtc.ts index a18bf0c..c9f1488 100644 --- a/webclient/src/helpers/webrtc.ts +++ b/webclient/src/helpers/webrtc.ts @@ -31,10 +31,25 @@ export async function initPeerConnection( } // ✅ Add local media - localStream.value = await navigator.mediaDevices.getUserMedia({ - audio: true, - video: true, - }); + try { + localStream.value = await navigator.mediaDevices.getUserMedia({ + audio: true, + video: true, + }); + } catch (error) { + console.warn("Error accessing media devices:", error); + try { + localStream.value = await navigator.mediaDevices.getUserMedia({ + audio: true, + }); + } catch (error) { + console.error("Error accessing audio devices:", error); + alert( + "Unable to access audio devices. Please check your microphone settings." + ); + return; + } + } localStream.value.getTracks().forEach((track) => { peerConnection.value?.addTrack(track, localStream.value!);