handleCallInterruptionCallbacks method

Future<void> handleCallInterruptionCallbacks(
  1. void onInterruptionStart()?,
  2. void onInterruptionEnd()?, {
  3. AndroidInterruptionSource androidInterruptionSource = AndroidInterruptionSource.audioFocusAndTelephony,
  4. @Deprecated('Audio focus is now handled in a way that does not require this parameter. It will be removed in the next major version.') AndroidAudioAttributesUsageType? androidAudioAttributesUsageType,
  5. @Deprecated('Audio focus is now handled in a way that does not require this parameter. It will be removed in the next major version.') AndroidAudioAttributesContentType? androidAudioAttributesContentType,
})

Implementation

Future<void> handleCallInterruptionCallbacks(
  void Function()? onInterruptionStart,
  void Function()? onInterruptionEnd, {
  AndroidInterruptionSource androidInterruptionSource =
      AndroidInterruptionSource.audioFocusAndTelephony,
  @Deprecated(
      'Audio focus is now handled in a way that does not require this parameter. It will be removed in the next major version.')
  AndroidAudioAttributesUsageType? androidAudioAttributesUsageType,
  @Deprecated(
      'Audio focus is now handled in a way that does not require this parameter. It will be removed in the next major version.')
  AndroidAudioAttributesContentType? androidAudioAttributesContentType,
}) async {
  if (!Platform.isAndroid && !Platform.isIOS) {
    throw UnimplementedError(
        'handleCallInterruptionCallbacks is only supported on Android and iOS');
  }

  await WebRTC.invokeMethod(
    'handleCallInterruptionCallbacks',
    <String, dynamic>{
      if (Platform.isAndroid)
        'androidInterruptionSource': androidInterruptionSource.name,
    },
  );

  final mediaDeviceNative = mediaDevices as MediaDeviceNative;
  mediaDeviceNative.onInterruptionStart = onInterruptionStart;
  mediaDeviceNative.onInterruptionEnd = onInterruptionEnd;
}