Fix office select device (#6422)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-08-28 19:42:47 +05:00 committed by GitHub
parent fb05209246
commit daac4666db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View File

@ -12,10 +12,12 @@
void Room.getLocalDevices().then(async (devices) => { void Room.getLocalDevices().then(async (devices) => {
devices.forEach((device) => { devices.forEach((device) => {
if (device.kind === 'audiooutput') { if (device.deviceId !== 'default') {
speakers.push({ label: device.label, id: device.deviceId }) if (device.kind === 'audiooutput') {
} else if (device.kind === 'audioinput') { speakers.push({ label: device.label, id: device.deviceId })
mics.push({ label: device.label, id: device.deviceId }) } else if (device.kind === 'audioinput') {
mics.push({ label: device.label, id: device.deviceId })
}
} }
}) })
if (speakers.length === 0) { if (speakers.length === 0) {

View File

@ -435,6 +435,18 @@ export async function setCam (value: boolean): Promise<void> {
export async function setMic (value: boolean): Promise<void> { export async function setMic (value: boolean): Promise<void> {
if ($isCurrentInstanceConnected) { 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 { try {
const opt: AudioCaptureOptions = {} const opt: AudioCaptureOptions = {}
const selectedDevice = localStorage.getItem(selectedMicId) const selectedDevice = localStorage.getItem(selectedMicId)