From 80ea53b7e94f8879059a4ef80685ef9bb71a8b4f Mon Sep 17 00:00:00 2001 From: Sharif Rahaman Date: Mon, 6 May 2024 10:38:43 -0700 Subject: [PATCH] Default mic and speaker --- Project/src/MakeCall/MakeCall.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Project/src/MakeCall/MakeCall.js b/Project/src/MakeCall/MakeCall.js index 6a9c3a0..ec2505e 100644 --- a/Project/src/MakeCall/MakeCall.js +++ b/Project/src/MakeCall/MakeCall.js @@ -418,7 +418,8 @@ export default class MakeCall extends React.Component { try { const speakers = await this.deviceManager.getSpeakers(); - const speakerDevice = speakers[0]; + // Select the default or first speaker device found. + const speakerDevice = speakers.find(speaker => speaker.isSystemDefault) ?? speakers[0]; if (!speakerDevice || speakerDevice.id === 'speaker:') { throw new Error('No speaker devices found.'); } else if (speakerDevice) { @@ -434,7 +435,8 @@ export default class MakeCall extends React.Component { try { const microphones = await this.deviceManager.getMicrophones(); - const microphoneDevice = microphones[0]; + // Select the default or first microphone device found. + const microphoneDevice = microphones.find(mic => mic.isSystemDefault) ?? microphones[0]; if (!microphoneDevice || microphoneDevice.id === 'microphone:') { throw new Error('No microphone devices found.'); } else {