Skip to content

If there are no cameras in the system, and then a camera is plugged i… #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Project/src/MakeCall/CallCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ 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]
Expand All @@ -151,7 +155,9 @@ export default class CallCard extends React.Component {

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.
// 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 needs to manually turn video on again.
this.setState(prevState => ({
...prevState,
cameraDeviceOptions: prevState.cameraDeviceOptions.filter(option => { return option.key !== removedCameraDevice.id })
Expand Down Expand Up @@ -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 });
Expand Down
Loading