From 3d7d7cf41e3cf06bc02d1bc238b92789d5791c86 Mon Sep 17 00:00:00 2001 From: Andrew Shini <13059204+superandrew213@users.noreply.github.com> Date: Tue, 1 Feb 2022 18:09:55 +1000 Subject: [PATCH 1/3] define sessionId --- react-native/src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/react-native/src/index.js b/react-native/src/index.js index 4b28ff5..16fe215 100644 --- a/react-native/src/index.js +++ b/react-native/src/index.js @@ -672,6 +672,7 @@ export class AbstractSession extends Session { * Cancels running the session. */ cancel() { + const sessionId = this.getSessionId(); if (sessionId === undefined) { return FFmpegKitReactNativeModule.cancel(); } else { From c63401acf34e9d4e218340b496729bab987815f8 Mon Sep 17 00:00:00 2001 From: Andrew Shini <13059204+superandrew213@users.noreply.github.com> Date: Tue, 1 Feb 2022 21:19:56 +1000 Subject: [PATCH 2/3] cancel only session with sessionId --- react-native/src/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/react-native/src/index.js b/react-native/src/index.js index 16fe215..98def74 100644 --- a/react-native/src/index.js +++ b/react-native/src/index.js @@ -671,11 +671,9 @@ export class AbstractSession extends Session { /** * Cancels running the session. */ - cancel() { + async cancel() { const sessionId = this.getSessionId(); - if (sessionId === undefined) { - return FFmpegKitReactNativeModule.cancel(); - } else { + if (sessionId !== undefined) { return FFmpegKitReactNativeModule.cancelSession(sessionId); } } From cb124749a848d395f7c5431af3dbc2e837d9b8a2 Mon Sep 17 00:00:00 2001 From: Andrew Shini <13059204+superandrew213@users.noreply.github.com> Date: Wed, 2 Feb 2022 22:02:14 +1000 Subject: [PATCH 3/3] reject if sessionId is not defined --- react-native/src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/react-native/src/index.js b/react-native/src/index.js index 98def74..3a39aa6 100644 --- a/react-native/src/index.js +++ b/react-native/src/index.js @@ -669,11 +669,13 @@ export class AbstractSession extends Session { } /** - * Cancels running the session. + * Cancels running the session. Only starts cancellation. Does not guarantee that session is cancelled when promise resolves. */ async cancel() { const sessionId = this.getSessionId(); - if (sessionId !== undefined) { + if (sessionId === undefined) { + return Promise.reject(new Error('sessionId is not defined')); + } else { return FFmpegKitReactNativeModule.cancelSession(sessionId); } }