Skip to content

Commit dc710a4

Browse files
committed
fix: Fallback to a video-only stream if getUserMedia fails when requesting audio.
1 parent 5d32386 commit dc710a4

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

browser/src/libs/media/camera.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ class Camera {
4040
this.width = width;
4141
this.height = height;
4242
if (audioId) this.audioId = audioId;
43-
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio });
43+
44+
try {
45+
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio });
46+
} catch {
47+
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio: false });
48+
}
4449
}
4550

4651
public async updateResolution(width: number, height: number) {

desktop/src/renderer/src/libs/media/camera.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ class Camera {
4040
this.width = width
4141
this.height = height
4242
if (audioId) this.audioId = audioId
43-
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio })
43+
44+
try {
45+
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio })
46+
} catch {
47+
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio: false })
48+
}
4449
}
4550

4651
public async updateResolution(width: number, height: number): Promise<void> {

0 commit comments

Comments
 (0)