Web SDK
Choose microphone and speaker
List devices and let the visitor choose.
const { microphones, speakers, canChooseSpeaker } = await WayloVoice.listDevices();
// To get names before a call: WayloVoice.listDevices({ requestPermission: true }), from a click.
const [microphone] = microphones; // empty until the visitor has allowed the mic
const [speaker] = speakers;
if (microphone) await wayloVoice.setMicrophoneDevice(microphone.deviceId); // before or during the call
if (canChooseSpeaker && speaker) await wayloVoice.setSpeakerDevice(speaker.deviceId);Listing
listDevices()never asks for permission. Until the visitor allows the microphone, the lists are empty or unnamed. List again whenstate.microphonebecomeson, and onnavigator.mediaDevices'devicechange.listDevices({ requestPermission: true })asks for the microphone first (call it from a click), closes it again and lists with names. It rejects withMICROPHONE_DENIEDif the visitor blocks it.
Speakers
canChooseSpeakeris false where the browser can't route audio to a chosen speaker (Safari and every iOS browser).setSpeakerDevice()then rejects withSPEAKER_UNAVAILABLE.- Firefox before 140 can choose a speaker but lists none. Hide the speaker picker whenever
speakersis empty.
When devices change
- A device chosen before
start()that is gone by then falls back to the system default, and the state shows the device in use. - Mid-call, a microphone that can't be opened rejects with
MICROPHONE_UNAVAILABLE(MICROPHONE_IN_USEwhen another app holds it,MICROPHONE_DENIEDwhen the browser blocks it). The call keeps a working microphone where it can. - A chosen microphone or speaker stays until it is unplugged; the call then moves to the system default (
'default'). - On
'default', Chrome and other Chromium browsers follow system default changes; Firefox and Safari keep the open microphone until it is unplugged. - An unplugged muted microphone stays
mutedand opens the system default on unmute. - A mid-call
erroreventMICROPHONE_UNAVAILABLEmeans no microphone is left or none could be opened, muted or not;microphoneis thenoff.