From daac4666db2de16dc48c52f538d06db6bf77cb57 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 28 Aug 2024 19:42:47 +0500 Subject: [PATCH] Fix office select device (#6422) Signed-off-by: Denis Bykhov --- .../src/components/MicSettingPopup.svelte | 10 ++++++---- plugins/love-resources/src/utils.ts | 12 ++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/plugins/love-resources/src/components/MicSettingPopup.svelte b/plugins/love-resources/src/components/MicSettingPopup.svelte index f7774677e2..db7be747a3 100644 --- a/plugins/love-resources/src/components/MicSettingPopup.svelte +++ b/plugins/love-resources/src/components/MicSettingPopup.svelte @@ -12,10 +12,12 @@ void Room.getLocalDevices().then(async (devices) => { devices.forEach((device) => { - if (device.kind === 'audiooutput') { - speakers.push({ label: device.label, id: device.deviceId }) - } else if (device.kind === 'audioinput') { - mics.push({ label: device.label, id: device.deviceId }) + if (device.deviceId !== 'default') { + if (device.kind === 'audiooutput') { + speakers.push({ label: device.label, id: device.deviceId }) + } else if (device.kind === 'audioinput') { + mics.push({ label: device.label, id: device.deviceId }) + } } }) if (speakers.length === 0) { diff --git a/plugins/love-resources/src/utils.ts b/plugins/love-resources/src/utils.ts index aea663d6f6..61920b6aec 100644 --- a/plugins/love-resources/src/utils.ts +++ b/plugins/love-resources/src/utils.ts @@ -435,6 +435,18 @@ export async function setCam (value: boolean): Promise { export async function setMic (value: boolean): Promise { if ($isCurrentInstanceConnected) { + try { + const speaker = localStorage.getItem(selectedSpeakerId) + if (speaker !== null) { + const devices = await LKRoom.getLocalDevices('audiooutput') + const available = devices.find((p) => p.deviceId === speaker) + if (available !== undefined) { + await lk.switchActiveDevice('audiooutput', speaker) + } + } + } catch (err) { + console.error(err) + } try { const opt: AudioCaptureOptions = {} const selectedDevice = localStorage.getItem(selectedMicId)