setOutputDevice method

Future<void> setOutputDevice(
  1. DeviceDetails device
)

Sets device with device as a currently used output device.

Implementation

Future<void> setOutputDevice(DeviceDetails device) async {
  Log.debug(
    'setOutputDevice(${device.id()}, ${device.label()}, ${device.speaker.name})',
    '$runtimeType',
  );

  // On mobile platforms there's no need to do `medea_jason` or `MediaUtils`
  // way of changing the output, since we're doing the same in `_setSpeaker()`
  // method, which does `AVAudioSession` and `AndroidAudioManager` stuff.
  if (_isMobile) {
    if (_isMobile && speaker.value != device.speaker) {
      speaker.value = device.speaker;
      await _setSpeaker();
    }

    return;
  }

  if (outputDevice.value?.deviceId() != device.deviceId()) {
    outputDevice.value = device;
    await _setOutputDevice();
  }
}