implement AbstractSession.cancel method on flutter

This commit is contained in:
Taner Sener 2022-05-20 23:18:00 +01:00
parent 10ef18ab6b
commit c3d1bff355
2 changed files with 15 additions and 2 deletions

View File

@ -428,5 +428,18 @@ class AbstractSession extends Session {
bool isMediaInformation() => false;
/// Cancels running the session.
void cancel() {}
Future<void> cancel() async {
try {
final int? sessionId = getSessionId();
await FFmpegKitConfig.init();
if (sessionId == null) {
return _platform.ffmpegKitCancel();
} else {
return _platform.ffmpegKitCancelSession(sessionId);
}
} on PlatformException catch (e, stack) {
print("Plugin cancel error: ${e.message}");
return Future.error("cancel failed.", stack);
}
}
}

View File

@ -106,5 +106,5 @@ abstract class Session {
bool isMediaInformation();
/// Cancels running the session.
void cancel();
Future<void> cancel();
}