isEncoderSupported method

Future<bool> isEncoderSupported(
  1. Codec codec
)

Returns true if the specified encoder is supported by flutter_sound on this platform.

This verb is useful to know if a particular codec is supported on the current platform; Returns a Future

Example:

        if ( await myRecorder.isEncoderSupported(Codec.opusOGG) ) doSomething;

isEncoderSupported is a method for legacy reason, but should be a static function.

Implementation

Future<bool> isEncoderSupported(Codec codec) async {
  // For encoding ogg/opus on ios, we need to support two steps :
  // - encode CAF/OPPUS (with native Apple AVFoundation)
  // - remux CAF file format to OPUS file format (with ffmpeg)
  await _waitOpen();
  if (_isInited != Initialized.fullyInitialized) {
    throw Exception('Recorder is not open');
  }
  var result = false;
  // For encoding ogg/opus on ios, we need to support two steps :
  // - encode CAF/OPPUS (with native Apple AVFoundation)
  // - remux CAF file format to OPUS file format (with ffmpeg)

  if ((codec == Codec.opusOGG) && (!kIsWeb) && (Platform.isIOS)) {
    //if (!await isFFmpegSupported( ))
    //result = false;
    //else
    result = await FlutterSoundRecorderPlatform.instance
        .isEncoderSupported(this, codec: Codec.opusCAF);
  } else {
    result = await FlutterSoundRecorderPlatform.instance
        .isEncoderSupported(this, codec: codec);
  }
  return result;
}