switchAudioDevice method

Future<void> switchAudioDevice(
  1. MediaDeviceInfo device
)

Implementation

Future<void> switchAudioDevice(MediaDeviceInfo device) async {
  _selectedAudioOutput = device;
  Span? switchAudioDeviceSpan;
  try {
    if (videoSDKTelemetery != null) {
      switchAudioDeviceSpan =
          videoSDKTelemetery!.trace(spanName: 'Switching AudioDevice');
    }
  } catch (error) {}

  if (!kIsWeb) {
    await navigator.mediaDevices
        .selectAudioOutput(AudioOutputOptions(deviceId: device.deviceId));
  } else {
    _peers.forEach((key, value) {
      value.audioRenderer?.audioOutput(device.deviceId);
    });
  }

  if (switchAudioDeviceSpan != null) {
    videoSDKTelemetery!.completeSpan(
        span: switchAudioDeviceSpan,
        status: StatusCode.ok,
        message: 'Switching AudioDevice Successful');
  }
}