setAudioOutputRoute method

  1. @override
Future<bool> setAudioOutputRoute(
  1. String deviceName
)

Set the specified audio output route by deviceName.
deviceName The device name of the specified audio output route must be in the audio output route list.
This function is only available for iOS platform.
Return true indicates success, otherwise false.

Implementation

@override
Future<bool> setAudioOutputRoute(String deviceName) async {
  if (!Platform.isIOS) {
    throw UnimplementedError('setAudioOutputRoute() is only implemented for iOS.');
  }
  var params = <String, dynamic>{};
  params.putIfAbsent("deviceName", () => deviceName);

  return await methodChannel
      .invokeMethod<bool>('setAudioOutputRoute', params)
      .then<bool>((bool? value) => value ?? false);
}