do not listen ActivityEventListener methods on react native, fixes #397
This commit is contained in:
parent
fd351b78c2
commit
5f601fbac7
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Taner Sener
|
||||
* Copyright (c) 2021-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
|
@ -47,7 +47,6 @@ import com.arthenica.ffmpegkit.Signal;
|
|||
import com.arthenica.ffmpegkit.Statistics;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.BaseActivityEventListener;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
|
@ -75,7 +74,7 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
|
||||
public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule {
|
||||
|
||||
public static final String LIBRARY_NAME = "ffmpeg-kit-react-native";
|
||||
public static final String PLATFORM_NAME = "android";
|
||||
|
@ -131,7 +130,6 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple
|
|||
this.asyncExecutorService = Executors.newFixedThreadPool(asyncWriteToPipeConcurrencyLimit);
|
||||
|
||||
if (reactContext != null) {
|
||||
reactContext.addLifecycleEventListener(this);
|
||||
registerGlobalCallbacks(reactContext);
|
||||
}
|
||||
}
|
||||
|
@ -151,19 +149,6 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple
|
|||
return "FFmpegKitReactNativeModule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostResume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostPause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostDestroy() {
|
||||
this.asyncExecutorService.shutdown();
|
||||
}
|
||||
|
||||
protected void registerGlobalCallbacks(final ReactApplicationContext reactContext) {
|
||||
FFmpegKitConfig.enableFFmpegSessionCompleteCallback(session -> {
|
||||
final DeviceEventManagerModule.RCTDeviceEventEmitter jsModule = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
||||
|
@ -984,6 +969,12 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple
|
|||
promise.resolve(toStringArray(Packages.getExternalLibraries()));
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void uninit(final Promise promise) {
|
||||
this.asyncExecutorService.shutdown();
|
||||
promise.resolve(null);
|
||||
}
|
||||
|
||||
protected void enableLogs() {
|
||||
logsEnabled.compareAndSet(false, true);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Taner Sener
|
||||
* Copyright (c) 2021-2022 Taner Sener
|
||||
*
|
||||
* This file is part of FFmpegKit.
|
||||
*
|
||||
|
@ -695,6 +695,10 @@ RCT_EXPORT_METHOD(getExternalLibraries:(RCTPromiseResolveBlock)resolve rejecter:
|
|||
resolve([Packages getExternalLibraries]);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(uninit:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
||||
resolve(nil);
|
||||
}
|
||||
|
||||
- (void)enableLogs {
|
||||
logsEnabled = true;
|
||||
}
|
||||
|
|
2
react-native/src/index.d.ts
vendored
2
react-native/src/index.d.ts
vendored
|
@ -92,6 +92,8 @@ declare module 'ffmpeg-kit-react-native' {
|
|||
|
||||
static init(): Promise<void>;
|
||||
|
||||
static uninit(): Promise<void>;
|
||||
|
||||
static enableRedirection(): Promise<void>;
|
||||
|
||||
static disableRedirection(): Promise<void>;
|
||||
|
|
9
react-native/src/index.js
vendored
9
react-native/src/index.js
vendored
|
@ -812,6 +812,15 @@ export class FFmpegKitConfig {
|
|||
await FFmpegKitInitializer.initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninitializes the library.
|
||||
*
|
||||
* Calling this method before application termination is recommended but not required.
|
||||
*/
|
||||
static async uninit() {
|
||||
return FFmpegKitReactNativeModule.uninit();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Enables log and statistics redirection.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user