exportVideo method
Future<File>
exportVideo(
- String srcPath,
- CropRect crop,
- DurationRange trim,
- VideoEncodeSettings settings, {
- void onProgress(
- double progress
- TransformCancelToken? cancelToken,
override
Crops srcPath to crop, clips it to trim, transcodes it per
settings, and returns the written file.
onProgress receives values in 0.0..1.0. cancelToken cancels the work
cooperatively; a cancelled export throws
TransformException with TransformFailure.cancelled.
Not implemented in 0.1.0 — throws UnimplementedError.
Implementation
@override
Future<File> exportVideo(
String srcPath,
CropRect crop,
DurationRange trim,
VideoEncodeSettings settings, {
void Function(double progress)? onProgress,
TransformCancelToken? cancelToken,
}) async {
videoExports.add(
FakeVideoExport(
srcPath: srcPath, crop: crop, trim: trim, settings: settings),
);
// Slice 2's scripted sequence and slice 5's mid-export hook compose here.
// Dropping either one silently breaks the other slice's tests.
final List<double>? script = scriptedProgress;
if (script == null) {
onProgress?.call(0);
} else {
for (final double value in script) {
onProgress?.call(value);
}
}
await _settle();
if (cancelToken?.isCancelled ?? false) {
throw const TransformException(TransformFailure.cancelled, 'cancelled');
}
await onExportVideo?.call((double progress) => onProgress?.call(progress));
if (cancelToken?.isCancelled ?? false) {
throw const TransformException(TransformFailure.cancelled, 'cancelled');
}
if (script == null) {
onProgress?.call(1);
}
return _write('vid_${_counter++}.mp4');
}