Skip to content

Commit 64b627f

Browse files
committed
下载逻辑优化
1 parent 3f8d15b commit 64b627f

36 files changed

+888
-233
lines changed

android/local.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sdk.dir=/Users/Waiting/Library/Android/sdk
22
flutter.sdk=/Users/Waiting/Library/flutter
3-
flutter.buildMode=release
3+
flutter.buildMode=debug
44
flutter.versionName=1.0.0
55
flutter.versionCode=3

build-dmg.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
create-dmg \
3+
--volname "Application Installer" \
4+
--volicon "/Users/Waiting/AndroidStudioProjects/TubeSavely/build/macos/Build/Products/Release/TubeSavely.app/Contents/Resources/AppIcon.icns" \
5+
--background "/Users/Waiting/AndroidStudioProjects/TubeSavely/assets/images/ic_feedback.png" \
6+
--window-pos 200 120 \
7+
--window-size 800 400 \
8+
--icon-size 100 \
9+
--icon "/Users/Waiting/AndroidStudioProjects/TubeSavely/assets/ic_logo.png" 200 190 \
10+
--hide-extension "TubeSavely.app" \
11+
--app-drop-link 600 185 \
12+
"/Users/Waiting/AndroidStudioProjects/TubeSavely/build/macos/TubeSavely.dmg" \
13+
"/Users/Waiting/AndroidStudioProjects/TubeSavely/build/macos/Build/Products/Release/TubeSavely.app/"
14+
#"Application-Installer.dmg"是.dmg文件名称。
15+
#"source_folder/"是"flutter build macos --release"结果路径,如:/工程目录/build/macos/Build/Products/Release/xxx.app
16+
17+
18+
hdiutil create -srcfolder build/macos/Build/Products/Release/TubeSavely.app TubeSavely.dmg
19+
hdiutil convert TubeSavely.dmg -format UDBZ -o Compressed_TubeSavely.dmg

build-ipa.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
flutter build ipa --obfuscate --split-debug-info=./symbols/

lib/core/callback/callback.dart

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
typedef SuccessCallback = Function(String);
2+
typedef ProgressCallback = Function(double);
3+
typedef FailureCallback = Function(Exception);

lib/core/converter/converter.dart

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'dart:io';
22

33
import 'package:path/path.dart' as path;
44
import 'package:path_provider/path_provider.dart';
5+
import 'package:tubesavely/core/callback/callback.dart';
6+
import 'package:tubesavely/generated/l10n.dart';
57
import 'package:tubesavely/utils/toast_util.dart';
68

79
import '../../model/emuns.dart';
@@ -12,18 +14,20 @@ class Converter {
1214
static Future<String> get baseOutputPath async =>
1315
'${Storage().getString(StorageKeys.CACHE_DIR_KEY) ?? (await getTemporaryDirectory()).path}/Convert';
1416

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 {
1619
Directory baseDirectory = Directory(await baseOutputPath);
1720
if (!baseDirectory.existsSync()) {
1821
baseDirectory.createSync(recursive: true);
1922
}
2023
String? extension = path.extension(videoPath);
2124
String newVideoPath = extension.isEmpty ? videoPath : videoPath.substring(0, videoPath.length - extension.length);
2225

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);
2529
if (savePath != null) {
26-
ToastUtil.success("视频转换成功");
30+
ToastUtil.success(S.current.toastConvertSuccess);
2731
return savePath;
2832
}
2933
return null;

0 commit comments

Comments
 (0)