我想更改file.path。(据此,压缩文件保存到android -> 数据目录)
import 'dart:io';
import 'package:video_compress/video_compress.dart';
class CompressVideos {
static Future<MediaInfo?> compressVideo(File file) async {
try {
await VideoCompress.setLogLevel(0);
return VideoCompress.compressVideo(
file.path,
quality: VideoQuality.LowQuality,
includeAudio: true,
);
} catch (e) {
VideoCompress.cancelCompression();
}
}
}
我想将压缩的视频保存到图库。
Future compressVideo() async {
showDialog(
context: context,
builder: (context) => const Dialog(
child: ProgressDialog(),
),
barrierDismissible: true,
);
final comprss = await CompressVideos.compressVideo(videoFile!);
setState(() {
compressedVideoDetails = comprss;
});
isVisible = false;
Navigator.pop(context);
}