FffmpegPlugin.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #import "FffmpegPlugin.h"
  2. #import <mobileffmpeg/ArchDetect.h>
  3. #import <mobileffmpeg/MobileFFmpegConfig.h>
  4. #import <mobileffmpeg/MobileFFmpeg.h>
  5. #import <mobileffmpeg/MobileFFprobe.h>
  6. @implementation FffmpegPlugin
  7. + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  8. FlutterMethodChannel* channel = [FlutterMethodChannel
  9. methodChannelWithName:@"fffmpeg"
  10. binaryMessenger:[registrar messenger]];
  11. FffmpegPlugin* instance = [[FffmpegPlugin alloc] init];
  12. [registrar addMethodCallDelegate:instance channel:channel];
  13. }
  14. - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  15. if ([@"getPlatformVersion" isEqualToString:call.method]) {
  16. result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
  17. }else if([@"exeCommand" isEqualToString:call.method]){
  18. NSArray* arguments = call.arguments[@"arguments"];
  19. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  20. int rc = [MobileFFmpeg executeWithArguments:arguments];
  21. NSLog(@"FFmpeg exited with rc: %d\n", rc);
  22. result(@"ok");
  23. });
  24. } else {
  25. result(FlutterMethodNotImplemented);
  26. }
  27. }
  28. @end