fix: use combine for method channel communication

This commit is contained in:
Prateek Sunal
2025-07-08 18:46:51 +05:30
parent 4604280ef8
commit f1d978fbf7
4 changed files with 22 additions and 12 deletions

View File

@@ -1,8 +1,7 @@
import "dart:async";
import "dart:io";
import "package:combine/combine.dart";
import "package:computer/computer.dart";
import "package:dart_ui_isolate/dart_ui_isolate.dart";
import "package:ffmpeg_kit_flutter/ffmpeg_kit.dart";
import "package:ffmpeg_kit_flutter/ffprobe_kit.dart";
import "package:ffmpeg_kit_flutter/media_information.dart";
@@ -18,14 +17,13 @@ class IsolatedFfmpegService {
}
static Future<Map> runFfmpeg(String command) async {
return await flutterCompute<Map, String>(
_ffmpegRun,
command,
);
return await CombineWorker()
.executeWithArg<Map, String>(_ffmpegRun, command);
}
static Future<Map> getVideoInfo(File file) async {
return flutterCompute<Map, String>(_getVideoProps, file.path);
static Future<Map> getVideoInfo(String file) async {
return await CombineWorker()
.executeWithArg<Map, String>(_getVideoProps, file);
}
}
@@ -56,9 +54,7 @@ Future<Map> _getVideoProps(String filePath) async {
}
@pragma('vm:entry-point')
Future<Map> _ffmpegRun(
String value,
) async {
Future<Map> _ffmpegRun(String value) async {
final session = await FFmpegKit.execute(value, true);
final returnCode = (await session.getReturnCode())?.getValue();

View File

@@ -70,7 +70,8 @@ Future<FFProbeProps?> getVideoPropsAsync(File originalFile) async {
try {
final stopwatch = Stopwatch()..start();
final mediaInfo = await IsolatedFfmpegService.getVideoInfo(originalFile);
final mediaInfo =
await IsolatedFfmpegService.getVideoInfo(originalFile.path);
if (mediaInfo.isEmpty) {
return null;
}

View File

@@ -324,6 +324,15 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
combine:
dependency: "direct main"
description:
path: "."
ref: "feat_version_3.32.0"
resolved-ref: "49a02bc7b2d3636f7c3dba294371959f9f60a513"
url: "https://github.com/mobaink/combine.git"
source: git
version: "0.5.8"
computer:
dependency: "direct main"
description:

View File

@@ -36,6 +36,10 @@ dependencies:
url: https://github.com/ente-io/chewie.git
ref: mybranched
collection: #dart
combine:
git:
url: https://github.com/mobaink/combine.git
ref: feat_version_3.32.0
computer: # logged task name in verbose in fork
git: "https://github.com/ente-io/computer.git"
connectivity_plus: ^6.0.2