changeMic

suspend fun changeMic(deviceId: String? = null)

Switches the call's audio route to the device deviceId names: it becomes the selected device, and a live mic is muted and unmuted on it. A muted mic stays muted; the next unmuteMic uses the new device.

Android has no separate list of microphones, so the devices are the audio routes VideoSDK.getMics lists — SPEAKER_PHONE, EARPIECE, WIRED_HEADSET, BLUETOOTH — and choosing one moves playback and capture together: a wired or Bluetooth headset records from its own microphone, the speaker and earpiece from the built-in one. NONE is also accepted and routes audio nowhere.

A failed switch restores the previous device as the selected one and rethrows, so a mic that failed is not used again by unmuteMic or by a reconnect.

Parameters

deviceId

the deviceId of a device from VideoSDK.getMics, or null for the device after the current one in that list, wrapping around

Throws

code 3059 (ERROR_NO_MICROPHONE_DEVICE_FOUND) if deviceId is not currently in VideoSDK.getMics, changing nothing; code 3034 (ERROR_MICROPHONE_ACCESS_UNAVAILABLE) if the device list cannot be read; code 3035 / 3065 if the room is not joined or is reconnecting; or any code muteMic or unmuteMic throws. 3059, 3035 and 3065 are also reported on RoomEventListener.onError.


suspend fun changeMic(customMicrophoneTrack: CustomStreamTrack)

Switches the microphone to customMicrophoneTrack: a live mic is muted and unmuted with the track, so its audio profile takes effect at once. A muted mic is simply unmuted with it, so the mic is on either way.

The track's audio profile replaces the room's stored audio config, so later unmuteMic calls keep it.

Nothing is rolled back on failure: a refused mute leaves the previous mic publishing and skips the unmute, and a failed unmute leaves nothing publishing.

Parameters

customMicrophoneTrack

Throws

code 3035 or 3065 if the room is not joined or is reconnecting (also reported on RoomEventListener.onError), or any code muteMic or unmuteMic throws.