From bd90c1e384f87fd2f5976da413cc156a4c167e8d Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Thu, 21 Mar 2024 20:11:33 +0100 Subject: [PATCH] Request audio only device when requesting of media devices fails with NotFound See #153 --- src/state.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/state.ts b/src/state.ts index 8163f5c..c029ed7 100644 --- a/src/state.ts +++ b/src/state.ts @@ -207,8 +207,13 @@ async function switchMedia() { delete constraints.video } } - - const media = await getUserMedia(constraints) + let media = await getUserMedia(constraints) + if (media.error) { + const audioOnly: MediaStreamConstraints = { + audio, + } + media = await getUserMedia(audioOnly) + } state.error = media.error stream = media.stream