@@ -2,6 +2,8 @@ import 'dart:io';
2
2
3
3
import 'package:path/path.dart' as path;
4
4
import 'package:path_provider/path_provider.dart' ;
5
+ import 'package:tubesavely/core/callback/callback.dart' ;
6
+ import 'package:tubesavely/generated/l10n.dart' ;
5
7
import 'package:tubesavely/utils/toast_util.dart' ;
6
8
7
9
import '../../model/emuns.dart' ;
@@ -12,18 +14,20 @@ class Converter {
12
14
static Future <String > get baseOutputPath async =>
13
15
'${Storage ().getString (StorageKeys .CACHE_DIR_KEY ) ?? (await getTemporaryDirectory ()).path }/Convert' ;
14
16
15
- static Future <String ?> convertToFormat (String videoPath, VideoFormat format, {ProgressCallback ? progressCallback}) async {
17
+ static Future <String ?> convertToFormat (String videoPath, VideoFormat format,
18
+ {ProgressCallback ? onProgress, FailureCallback ? onFailure}) async {
16
19
Directory baseDirectory = Directory (await baseOutputPath);
17
20
if (! baseDirectory.existsSync ()) {
18
21
baseDirectory.createSync (recursive: true );
19
22
}
20
23
String ? extension = path.extension (videoPath);
21
24
String newVideoPath = extension .isEmpty ? videoPath : videoPath.substring (0 , videoPath.length - extension .length);
22
25
23
- String outputPath = '${(baseDirectory .path )}/${path .basename (newVideoPath )}.${format .name }' ;
24
- String ? savePath = await FFmpegExecutor .convert (videoPath, outputPath: outputPath, progressCallback: progressCallback);
26
+ String outputPath = '${(baseDirectory .path )}/${path .basename (newVideoPath )}.${format .name .replaceAll ('_' , '' )}' ;
27
+ String ? savePath =
28
+ await FFmpegExecutor .convert (videoPath, outputPath: outputPath, onProgress: onProgress, onFailure: onFailure);
25
29
if (savePath != null ) {
26
- ToastUtil .success ("视频转换成功" );
30
+ ToastUtil .success (S .current.toastConvertSuccess );
27
31
return savePath;
28
32
}
29
33
return null ;
0 commit comments