set global callbacks when plugin is initialised on flutter, fixes #209

This commit is contained in:
Taner Sener 2021-11-02 14:19:44 +00:00
parent fcd00c6850
commit 305c14f4aa
3 changed files with 12 additions and 6 deletions

View File

@ -150,7 +150,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
this.asyncWriteToPipeExecutorService = Executors.newFixedThreadPool(asyncWriteToPipeConcurrencyLimit); this.asyncWriteToPipeExecutorService = Executors.newFixedThreadPool(asyncWriteToPipeConcurrencyLimit);
this.resultHandler = new FFmpegKitFlutterMethodResultHandler(); this.resultHandler = new FFmpegKitFlutterMethodResultHandler();
registerGlobalCallbacks(); Log.d(LIBRARY_NAME, String.format("FFmpegKitFlutterPlugin created %s.", this));
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -192,7 +192,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
@Override @Override
public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) { public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) {
Log.d(LIBRARY_NAME, String.format("FFmpegKitFlutterPlugin attached to activity %s.", activityPluginBinding.getActivity())); Log.d(LIBRARY_NAME, String.format("FFmpegKitFlutterPlugin %s attached to activity %s.", this, activityPluginBinding.getActivity()));
init(flutterPluginBinding.getBinaryMessenger(), flutterPluginBinding.getApplicationContext(), activityPluginBinding.getActivity(), null, activityPluginBinding); init(flutterPluginBinding.getBinaryMessenger(), flutterPluginBinding.getApplicationContext(), activityPluginBinding.getActivity(), null, activityPluginBinding);
} }
@ -215,7 +215,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
@Override @Override
public void onListen(final Object o, final EventChannel.EventSink eventSink) { public void onListen(final Object o, final EventChannel.EventSink eventSink) {
this.eventSink = eventSink; this.eventSink = eventSink;
Log.d(LIBRARY_NAME, String.format("FFmpegKitFlutterPlugin started listening to events on %s.", eventSink)); Log.d(LIBRARY_NAME, String.format("FFmpegKitFlutterPlugin %s started listening to events on %s.", this, eventSink));
} }
@Override @Override
@ -615,6 +615,8 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected void init(final BinaryMessenger messenger, final Context context, final Activity activity, final io.flutter.plugin.common.PluginRegistry.Registrar registrar, final ActivityPluginBinding activityBinding) { protected void init(final BinaryMessenger messenger, final Context context, final Activity activity, final io.flutter.plugin.common.PluginRegistry.Registrar registrar, final ActivityPluginBinding activityBinding) {
registerGlobalCallbacks();
if (methodChannel == null) { if (methodChannel == null) {
methodChannel = new MethodChannel(messenger, METHOD_CHANNEL); methodChannel = new MethodChannel(messenger, METHOD_CHANNEL);
methodChannel.setMethodCallHandler(this); methodChannel.setMethodCallHandler(this);
@ -640,7 +642,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
activityBinding.addActivityResultListener(this); activityBinding.addActivityResultListener(this);
} }
Log.d(LIBRARY_NAME, String.format("FFmpegKitFlutterPlugin initialized with context %s and activity %s.", context, activity)); Log.d(LIBRARY_NAME, String.format("FFmpegKitFlutterPlugin %s initialised with context %s and activity %s.", this, context, activity));
} }
protected void uninit() { protected void uninit() {

View File

@ -81,7 +81,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
statisticsEnabled = false; statisticsEnabled = false;
asyncWriteToPipeDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); asyncWriteToPipeDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
[self registerGlobalCallbacks]; NSLog(@"FFmpegKitFlutterPlugin %p created.\n", self);
} }
return self; return self;
@ -89,6 +89,8 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
- (FlutterError *)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)eventSink { - (FlutterError *)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)eventSink {
_eventSink = eventSink; _eventSink = eventSink;
NSLog(@"FFmpegKitFlutterPlugin %p started listening to events on %p.\n", self, eventSink);
[self registerGlobalCallbacks];
return nil; return nil;
} }

View File

@ -81,7 +81,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
statisticsEnabled = false; statisticsEnabled = false;
asyncWriteToPipeDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); asyncWriteToPipeDispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
[self registerGlobalCallbacks]; NSLog(@"FFmpegKitFlutterPlugin %p created.\n", self);
} }
return self; return self;
@ -89,6 +89,8 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
- (FlutterError *)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)eventSink { - (FlutterError *)onListenWithArguments:(id)arguments eventSink:(FlutterEventSink)eventSink {
_eventSink = eventSink; _eventSink = eventSink;
NSLog(@"FFmpegKitFlutterPlugin %p started listening to events on %p.\n", self, eventSink);
[self registerGlobalCallbacks];
return nil; return nil;
} }