From 56935949d815fbdef1c0ce689e860d8932306c8f Mon Sep 17 00:00:00 2001 From: Christopher Whilar Date: Mon, 26 Aug 2024 18:56:57 -0400 Subject: [PATCH 1/3] If there are no cameras in the system, and then a camera is plugged in, select it for use --- Project/src/MakeCall/CallCard.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Project/src/MakeCall/CallCard.js b/Project/src/MakeCall/CallCard.js index 0c132f4..7c80ccc 100644 --- a/Project/src/MakeCall/CallCard.js +++ b/Project/src/MakeCall/CallCard.js @@ -146,12 +146,18 @@ export default class CallCard extends React.Component { this.setState(prevState => ({ ...prevState, cameraDeviceOptions: [...prevState.cameraDeviceOptions, addedCameraDeviceOption] - })); + }), () => { + // If there are no cameras in the system and then a camera is plugged in / enabled, select it for use. + if (!this.state.selectedCameraDeviceId) { + this.setState({ selectedCameraDeviceId: addedCameraDevice.id }); + } + }); }); e.removed.forEach(async removedCameraDevice => { // If the selected camera is removed, select a new camera. - // Note: When the selected camera is removed, the calling sdk automatically turns video off. + // When the selected camera is removed, the calling sdk automatically turns video off. + // User need to manually turn video on again this.setState(prevState => ({ ...prevState, cameraDeviceOptions: prevState.cameraDeviceOptions.filter(option => { return option.key !== removedCameraDevice.id }) @@ -211,11 +217,6 @@ export default class CallCard extends React.Component { this.callFinishConnectingResolve(); } } - if (this.call.state === 'Incoming') { - this.setState({ selectedCameraDeviceId: cameraDevices[0]?.id }); - this.setState({ selectedSpeakerDeviceId: speakerDevices[0]?.id }); - this.setState({ selectedMicrophoneDeviceId: microphoneDevices[0]?.id }); - } if (this.call.state !== 'Disconnected') { this.setState({ callState: this.call.state }); From dded1b3d5f8d65e74769af5698cc16e84464074a Mon Sep 17 00:00:00 2001 From: Christopher Whilar Date: Mon, 26 Aug 2024 19:07:18 -0400 Subject: [PATCH 2/3] clean up --- Project/src/MakeCall/CallCard.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Project/src/MakeCall/CallCard.js b/Project/src/MakeCall/CallCard.js index 7c80ccc..f3e2611 100644 --- a/Project/src/MakeCall/CallCard.js +++ b/Project/src/MakeCall/CallCard.js @@ -143,21 +143,21 @@ export default class CallCard extends React.Component { this.deviceManager.on('videoDevicesUpdated', async e => { e.added.forEach(addedCameraDevice => { const addedCameraDeviceOption = { key: addedCameraDevice.id, text: addedCameraDevice.name }; + // If there were no cameras in the system and then a camera is plugged in / enabled, select it for use. + if (this.state.cameraDeviceOptions.length === 0 && !this.state.selectedCameraDeviceId) { + this.setState({ selectedCameraDeviceId: addedCameraDevice.id }); + } this.setState(prevState => ({ ...prevState, cameraDeviceOptions: [...prevState.cameraDeviceOptions, addedCameraDeviceOption] - }), () => { - // If there are no cameras in the system and then a camera is plugged in / enabled, select it for use. - if (!this.state.selectedCameraDeviceId) { - this.setState({ selectedCameraDeviceId: addedCameraDevice.id }); - } - }); + })); }); e.removed.forEach(async removedCameraDevice => { // If the selected camera is removed, select a new camera. + // If there are no other cameras, then just set this.state.selectedCameraDeviceId to undefined. // When the selected camera is removed, the calling sdk automatically turns video off. - // User need to manually turn video on again + // User needs to manually turn video on again. this.setState(prevState => ({ ...prevState, cameraDeviceOptions: prevState.cameraDeviceOptions.filter(option => { return option.key !== removedCameraDevice.id }) From 6eec3de4cbc2a0bc8cb54b91b877924ebf3db7ec Mon Sep 17 00:00:00 2001 From: Christopher Whilar Date: Mon, 26 Aug 2024 19:07:49 -0400 Subject: [PATCH 3/3] tab --- Project/src/MakeCall/CallCard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project/src/MakeCall/CallCard.js b/Project/src/MakeCall/CallCard.js index f3e2611..be8e746 100644 --- a/Project/src/MakeCall/CallCard.js +++ b/Project/src/MakeCall/CallCard.js @@ -143,8 +143,8 @@ export default class CallCard extends React.Component { this.deviceManager.on('videoDevicesUpdated', async e => { e.added.forEach(addedCameraDevice => { const addedCameraDeviceOption = { key: addedCameraDevice.id, text: addedCameraDevice.name }; - // If there were no cameras in the system and then a camera is plugged in / enabled, select it for use. - if (this.state.cameraDeviceOptions.length === 0 && !this.state.selectedCameraDeviceId) { + // If there were no cameras in the system and then a camera is plugged in / enabled, select it for use. + if (this.state.cameraDeviceOptions.length === 0 && !this.state.selectedCameraDeviceId) { this.setState({ selectedCameraDeviceId: addedCameraDevice.id }); } this.setState(prevState => ({