isEncoderSupported method

Future<bool> isEncoderSupported(
  1. TauCodec 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(TauCodec 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) {
    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 is Opus) && (!kIsWeb) && (Platform.isIOS)) {
    //if (!await isFFmpegSupported( ))
    //result = false;
    //else
    result = await TauRecorderPlatform.instance
        .isEncoderSupported(this, codec: Codec.opusCAF);
  } else {
    result = await TauRecorderPlatform.instance
        .isEncoderSupported(this, codec: codec.deprecatedCodec);
  }
  return result;
}