useMediaDevice Hook Event Callbacks - React Native
onAudioDeviceChanged()
onAudioDeviceChanged()is a callback which gets triggered when an audio device, such as a wired headset or a Bluetooth device, is connected or removed.- It receives a
Map<string, MicrophoneDeviceInfo>of the available audio devices, keyed bydeviceId. - Microphone permission must be granted, or the callback does not receive the list.
Example
import { useMediaDevice } from "@videosdk.live/react-native-sdk";
function AudioDeviceWatcher() {
useMediaDevice({
onAudioDeviceChanged: (devices) => {
devices.forEach((device, deviceId) => {
console.log("Audio device", deviceId, device);
});
},
});
return null;
}
Got a Question? Ask us on discord

