compress method

  1. @override
Future<VideoCompressResult> compress(
  1. String id,
  2. String path,
  3. VideoCompressConfig config,
  4. String? outputPath,
)
override

Compress path using config. id identifies the job (for progress correlation and cancellation). When outputPath is non-null the encoded file is written there; otherwise it lands in the plugin cache.

Implementation

@override
Future<VideoCompressResult> compress(
  String id,
  String path,
  VideoCompressConfig config,
  String? outputPath,
) async {
  try {
    final res = await _method.invokeMethod<Map<dynamic, dynamic>>(
      'compress',
      {
        'id': id,
        'path': path,
        'config': config.toMap(),
        'outputPath': outputPath,
      },
    );
    return VideoCompressResult.fromMap(res!);
  } on PlatformException catch (e) {
    if (e.code == 'cancelled') {
      throw VideoCompressCancelledException(e.message);
    }
    throw VideoCompressException(e.code, e.message);
  }
}