Browse Source

fix some problem

cjl_macbook 6 years ago
parent
commit
40c54989ad

+ 4 - 4
example/ios/Podfile.lock

@@ -7,16 +7,16 @@ PODS:
 
 DEPENDENCIES:
   - Flutter (from `.symlinks/flutter/ios`)
-  - flutter_ijkplayer (from `/Volumes/Evo512/code/flutter/plugins/ijkplayer/ios/flutter_ijkplayer.podspec`)
-  - photo_manager (from `/Users/cai/.pub-cache/hosted/pub.flutter-io.cn/photo_manager-0.3.2/ios/photo_manager.podspec`)
+  - flutter_ijkplayer (from `/Users/caijinglong/Documents/GitHub/flutter_ijkplayer/ios/flutter_ijkplayer.podspec`)
+  - photo_manager (from `/Users/caijinglong/.pub-cache/hosted/pub.flutter-io.cn/photo_manager-0.3.2/ios/photo_manager.podspec`)
 
 EXTERNAL SOURCES:
   Flutter:
     :path: ".symlinks/flutter/ios"
   flutter_ijkplayer:
-    :path: "/Volumes/Evo512/code/flutter/plugins/ijkplayer/ios/flutter_ijkplayer.podspec"
+    :path: "/Users/caijinglong/Documents/GitHub/flutter_ijkplayer/ios/flutter_ijkplayer.podspec"
   photo_manager:
-    :path: "/Users/cai/.pub-cache/hosted/pub.flutter-io.cn/photo_manager-0.3.2/ios/photo_manager.podspec"
+    :path: "/Users/caijinglong/.pub-cache/hosted/pub.flutter-io.cn/photo_manager-0.3.2/ios/photo_manager.podspec"
 
 SPEC CHECKSUMS:
   Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296

+ 5 - 1
example/ios/Runner.xcodeproj/project.pbxproj

@@ -107,7 +107,6 @@
 				97C146EF1CF9000F007C117D /* Products */,
 				2ABB07C25A743DD406317260 /* Pods */,
 				6E7E052C96895F1848299B95 /* Frameworks */,
-				17FCB4C9246909762D05E086 /* FLTVideoPlayer.m */,
 			);
 			sourceTree = "<group>";
 		};
@@ -179,6 +178,11 @@
 				TargetAttributes = {
 					97C146ED1CF9000F007C117D = {
 						CreatedOnToolsVersion = 7.3.1;
+						SystemCapabilities = {
+							com.apple.BackgroundModes = {
+								enabled = 1;
+							};
+						};
 					};
 				};
 			};

+ 7 - 2
example/ios/Runner/Info.plist

@@ -22,6 +22,13 @@
 	<string>$(FLUTTER_BUILD_NUMBER)</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
+	<key>NSPhotoLibraryUsageDescription</key>
+	<string>App need your agree, can visit your album</string>
+	<key>UIBackgroundModes</key>
+	<array>
+		<string>fetch</string>
+		<string>remote-notification</string>
+	</array>
 	<key>UILaunchStoryboardName</key>
 	<string>LaunchScreen</string>
 	<key>UIMainStoryboardFile</key>
@@ -41,7 +48,5 @@
 	</array>
 	<key>UIViewControllerBasedStatusBarAppearance</key>
 	<false/>
-    <key>NSPhotoLibraryUsageDescription</key>
-    <string>App need your agree, can visit your album</string>
 </dict>
 </plist>

+ 3 - 3
example/pubspec.lock

@@ -80,7 +80,7 @@ packages:
       name: pedantic
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.5.0"
+    version: "1.4.0"
   photo:
     dependency: "direct main"
     description:
@@ -113,7 +113,7 @@ packages:
       name: source_span
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.5.5"
+    version: "1.5.3"
   stack_trace:
     dependency: transitive
     description:
@@ -164,4 +164,4 @@ packages:
     source: hosted
     version: "2.0.8"
 sdks:
-  dart: ">=2.1.1-dev.0.0 <3.0.0"
+  dart: ">=2.1.0 <3.0.0"

+ 5 - 3
ios/Classes/FlutterIJK.m

@@ -24,7 +24,6 @@
     self = [super init];
     if (self) {
         self.registrar = registrar;
-        IJKMPMoviePlayerController *controller = [[IJKMPMoviePlayerController alloc] initWithContentURLString:@""];
         NSObject <FlutterTextureRegistry> *textures = [self.registrar textures];
         player = [IJKVideoPlayer new];
         textureId = [textures registerTexture:player];
@@ -79,9 +78,12 @@
     return self;
 }
 
-
 - (CVPixelBufferRef _Nullable)copyPixelBuffer {
-    return [self.controller framePixelbuffer];
+    [self.controller framePixelbufferLock];
+    CVPixelBufferRef pixelBuffer = [self.controller framePixelbuffer];
+    [self.controller framePixelbufferUnlock];
+    NSLog(@"buffer = %@",pixelBuffer);
+    return pixelBuffer;
 }
 
 - (void)setDataSource:(NSString *)uri {

+ 66 - 57
ios/Classes/IjkplayerPlugin.m

@@ -11,72 +11,81 @@
 @end
 
 @implementation IjkplayerPlugin {
-  FlutterIjkManager *manager;
+    FlutterIjkManager *manager;
+
 }
 
 - (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
-  self = [super init];
-  if (self) {
-    self.registrar = registrar;
-    manager = [FlutterIjkManager managerWithRegistrar:registrar];
-  }
+    self = [super init];
+    if (self) {
+        self.registrar = registrar;
+        manager = [FlutterIjkManager managerWithRegistrar:registrar];
+    }
 
-  return self;
+    return self;
 }
 
 + (instancetype)pluginWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
-  return [[self alloc] initWithRegistrar:registrar];
+    return [[self alloc] initWithRegistrar:registrar];
 }
 
 
-+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
-  FlutterMethodChannel* channel = [FlutterMethodChannel
-          methodChannelWithName:@"top.kikt/ijkplayer"
-                binaryMessenger:[registrar messenger]];
-  IjkplayerPlugin *instance = [IjkplayerPlugin pluginWithRegistrar:registrar];
-  [registrar addMethodCallDelegate:instance channel:channel];
++ (void)registerWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
+    FlutterMethodChannel *channel = [FlutterMethodChannel
+            methodChannelWithName:@"top.kikt/ijkplayer"
+                  binaryMessenger:[registrar messenger]];
+    IjkplayerPlugin *instance = [IjkplayerPlugin pluginWithRegistrar:registrar];
+    [registrar addMethodCallDelegate:instance channel:channel];
 }
 
-- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
-  if ([@"create" isEqualToString:call.method]) {
-    @try {
-      int64_t id = [manager create];
-      result(@(id));
-    }
-    @catch (NSException *exception) {
-      result([FlutterError errorWithCode:@"1" message:@"创建失败" details:exception]);
-    }
-  } else if ([@"dispose" isEqualToString:call.method]) {
-    int64_t id = [call getId];
-    [manager disposeWithId:id];
-  } else if ([@"play" isEqualToString:call.method]) {
-    FlutterIJK *ijk = [manager findIJKWithId:call.getId];
-    if (ijk) {
-      [ijk play];
-      result(@(1));
-    }
-  } else if ([@"pause" isEqualToString:call.method]) {
-    FlutterIJK *ijk = [manager findIJKWithId:[call getId]];
-    if (ijk) {
-      [ijk pause];
-    }
-  } else if ([@"stop" isEqualToString:call.method]) {
-    FlutterIJK *ijk = [manager findIJKWithId:[call getId]];
-    if (ijk) {
-      [ijk stop];
-    }
-  } else if ([@"setDataSource" isEqualToString:call.method]) {
-    FlutterIJK *ijk = [manager findIJKWithId:[call getIdParamFromDict]];
-    if (ijk) {
-      NSString *uri = [call getStringParam:@"uri"];
-      [ijk setDateSourceWithUri:uri];
-      result(nil);
-    } else {
-      result([FlutterError errorWithCode:@"1" message:@"设置失败" details:nil]);
-    }
-  } else {
-    result(FlutterMethodNotImplemented);
-  }
+- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
+    dispatch_queue_t mainQueue = dispatch_get_main_queue();
+    dispatch_async(mainQueue, ^{
+        if ([@"create" isEqualToString:call.method]) {
+            @try {
+                int64_t id = [self->manager create];
+                result(@(id));
+            }
+            @catch (NSException *exception) {
+                result([FlutterError errorWithCode:@"1" message:@"创建失败" details:exception]);
+            }
+        } else if ([@"dispose" isEqualToString:call.method]) {
+            int64_t id = [call getId];
+            [self->manager disposeWithId:id];
+        } else if ([@"play" isEqualToString:call.method]) {
+            FlutterIJK *ijk = [self->manager findIJKWithId:call.getId];
+            if (ijk) {
+                [ijk play];
+                result(@(1));
+            }
+        } else if ([@"pause" isEqualToString:call.method]) {
+            FlutterIJK *ijk = [self->manager findIJKWithId:[call getId]];
+            if (ijk) {
+                [ijk pause];
+            }
+        } else if ([@"stop" isEqualToString:call.method]) {
+            FlutterIJK *ijk = [self->manager findIJKWithId:[call getId]];
+            if (ijk) {
+                [ijk stop];
+            }
+        } else if ([@"setDataSource" isEqualToString:call.method]) {
+            FlutterIJK *ijk = [self->manager findIJKWithId:[call getIdParamFromDict]];
+            if (ijk) {
+                NSString *uri = [call getStringParam:@"uri"];
+                [ijk setDateSourceWithUri:uri];
+                result(nil);
+            } else {
+                result([FlutterError errorWithCode:@"1" message:@"设置失败" details:nil]);
+            }
+        } else {
+            result(FlutterMethodNotImplemented);
+        }
+    });
+}
+
+- (void)runOnUI:(DISPATCH_NOESCAPE dispatch_block_t)block {
+    dispatch_queue_t mainQueue = dispatch_get_main_queue();
+    dispatch_sync(mainQueue, block);
 }
 
 @end
@@ -84,15 +93,15 @@
 @implementation FlutterMethodCall (Ijk)
 
 - (int64_t)getId {
-  return [[self arguments] intValue];
+    return [[self arguments] intValue];
 }
 
 - (int64_t)getIdParamFromDict {
-  return [[self arguments][@"id"] intValue];
+    return [[self arguments][@"id"] intValue];
 }
 
 - (NSString *)getStringParam:(NSString *)key {
-  return [self arguments][key];
+    return [self arguments][key];
 }
 
 @end