compressFile method
compressFile
Implementation
@override
Future<String?> compressFile({
required String inputPath,
}) async {
final file = inputPath.split('/').last;
final dir = inputPath.substring(0, inputPath.lastIndexOf('/'));
String outputPath = "";
final nameParts = file.split('.');
if (nameParts.length < 2) return inputPath; // fallback
final name = nameParts.sublist(0, nameParts.length - 1).join('.');
final ext = nameParts.last;
outputPath = '$dir/${name}_compressed.$ext';
if (outputPath.contains(".temp")) {
outputPath = outputPath.replaceAll(".temp", ".mp4");
}
return await methodChannel.invokeMethod<String?>('compressFile', {
'inputPath': inputPath,
'outputPath': outputPath,
});
}