diff --git a/flutter/flutter/lib/abstract_session.dart b/flutter/flutter/lib/abstract_session.dart index 4667569..36d717d 100644 --- a/flutter/flutter/lib/abstract_session.dart +++ b/flutter/flutter/lib/abstract_session.dart @@ -428,5 +428,18 @@ class AbstractSession extends Session { bool isMediaInformation() => false; /// Cancels running the session. - void cancel() {} + Future 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); + } + } } diff --git a/flutter/flutter/lib/session.dart b/flutter/flutter/lib/session.dart index 7fe16ae..a4796d8 100644 --- a/flutter/flutter/lib/session.dart +++ b/flutter/flutter/lib/session.dart @@ -106,5 +106,5 @@ abstract class Session { bool isMediaInformation(); /// Cancels running the session. - void cancel(); + Future cancel(); }