From 25b1548f5c01164967739825bd8f9d24153bb1b4 Mon Sep 17 00:00:00 2001 From: xdzqyyds <2292136545@qq.com> Date: Tue, 19 Nov 2024 12:35:52 +0800 Subject: [PATCH 1/3] fix only one device --- webapp/components/device.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/webapp/components/device.tsx b/webapp/components/device.tsx index ba1e936..7659fee 100644 --- a/webapp/components/device.tsx +++ b/webapp/components/device.tsx @@ -68,8 +68,18 @@ export default function DeviceBar(props: { streamId: string }) { const updateDeviceList = async () => { // to obtain non-empty device label, there needs to be an active media stream or persistent permission // https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/label#value - await navigator.mediaDevices.getUserMedia({ audio: true, video: true }) - + try { + await navigator.mediaDevices.getUserMedia({ audio: true, video: true }) + } catch { + try { + await navigator.mediaDevices.getUserMedia({ audio: true }) + } catch { /* empty */ } + + try { + await navigator.mediaDevices.getUserMedia({ video: true }) + } catch { /* empty */ } + } + const devices = (await navigator.mediaDevices.enumerateDevices()).filter(i => !!i.deviceId) const audios = devices.filter(i => i.kind === 'audioinput').map(toDevice) @@ -97,7 +107,16 @@ export default function DeviceBar(props: { streamId: string }) { // - Android Web Browser // - Wechat WebView await permissionsQuery() - } catch { /* empty */ } + } catch { + try { + (await navigator.mediaDevices.getUserMedia({ audio: true })).getTracks().map(track => track.stop()) + await permissionsQuery() + } catch { /* empty */ } + try { + (await navigator.mediaDevices.getUserMedia({ video: true })).getTracks().map(track => track.stop()) + await permissionsQuery() + } catch { /* empty */ } + } await updateDeviceList() } From 9cee18d7276601f4eb2c4201b0bb1bbe6c651177 Mon Sep 17 00:00:00 2001 From: xdzqyyds <2292136545@qq.com> Date: Tue, 19 Nov 2024 13:35:27 +0800 Subject: [PATCH 2/3] CLA --- .github/CLA.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CLA.md b/.github/CLA.md index e42e4a6..d295bbd 100644 --- a/.github/CLA.md +++ b/.github/CLA.md @@ -47,3 +47,4 @@ Example: - Hongcha Zhang, @hongcha98, 2024/10/24 - Winter Zhang, @WinterJack002, 2024/10/26 - Rocket Aaron, @rocka, 2024/11/06 +- xdzqyyds, @xdzqyyds, 2024/11/19 From 7a9724a63422530effb40710a23c708ec40a5589 Mon Sep 17 00:00:00 2001 From: xdzqyyds <2292136545@qq.com> Date: Tue, 19 Nov 2024 13:37:04 +0800 Subject: [PATCH 3/3] Add xdzqyyds to CLA Signed-off-by: xdzqyyds <2292136545@qq.com> --- .github/CLA.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CLA.md b/.github/CLA.md index d295bbd..2137ce9 100644 --- a/.github/CLA.md +++ b/.github/CLA.md @@ -47,4 +47,4 @@ Example: - Hongcha Zhang, @hongcha98, 2024/10/24 - Winter Zhang, @WinterJack002, 2024/10/26 - Rocket Aaron, @rocka, 2024/11/06 -- xdzqyyds, @xdzqyyds, 2024/11/19 +- xdzqyyds, @xdzqyyds, 2024/11/19 \ No newline at end of file