mirror of
https://github.com/sipeed/NanoKVM-USB.git
synced 2026-09-11 05:59:57 -05:00
fix: Fallback to a video-only stream if getUserMedia fails when requesting audio.
This commit is contained in:
@@ -40,7 +40,12 @@ class Camera {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
if (audioId) this.audioId = audioId;
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio });
|
||||
|
||||
try {
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio });
|
||||
} catch {
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio: false });
|
||||
}
|
||||
}
|
||||
|
||||
public async updateResolution(width: number, height: number) {
|
||||
|
||||
@@ -40,7 +40,12 @@ class Camera {
|
||||
this.width = width
|
||||
this.height = height
|
||||
if (audioId) this.audioId = audioId
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio })
|
||||
|
||||
try {
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio })
|
||||
} catch {
|
||||
this.stream = await navigator.mediaDevices.getUserMedia({ video, audio: false })
|
||||
}
|
||||
}
|
||||
|
||||
public async updateResolution(width: number, height: number): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user