setIosAudioCategory method

Future<void> setIosAudioCategory(
  1. IosAudioCategory category
)

Sets the iOS audio category.

Only supported on iOS; no-op otherwise.

Implementation

Future<void> setIosAudioCategory(IosAudioCategory category) async {
  const Map<IosAudioCategory, String> categoryToString =
      <IosAudioCategory, String>{
    IosAudioCategory.ambientSolo: iosAudioCategoryAmbientSolo,
    IosAudioCategory.ambientMixed: iosAudioCategoryAmbientMixed,
    IosAudioCategory.playback: iosAudioCategoryPlayback
  };
  if (!Platform.isIOS) return;
  try {
    await audioMethodChannel.invokeMethod<dynamic>(iosAudioCategoryMethod,
        <String, dynamic>{iosAudioCategoryKey: categoryToString[category]});
  } on PlatformException catch (e) {
    _logger.severe('setIosAudioCategory error, category: $category', e);
  }
}