|
@@ -4,9 +4,7 @@
|
|
|
|
|
|
|
|
#import "CoolFlutterIJK.h"
|
|
#import "CoolFlutterIJK.h"
|
|
|
#import "CoolVideoInfo.h"
|
|
#import "CoolVideoInfo.h"
|
|
|
-#import "CoolIjkNotifyChannel.h"
|
|
|
|
|
-#import <IJKMediaFramework/IJKMediaFramework.h>
|
|
|
|
|
-#import <IJKMediaFramework/IJKMediaPlayer.h>
|
|
|
|
|
|
|
+#import "CoolFlutterResult.h"
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
#import <libkern/OSAtomic.h>
|
|
#import <libkern/OSAtomic.h>
|
|
|
|
|
|
|
@@ -22,6 +20,7 @@
|
|
|
FlutterMethodChannel *channel;
|
|
FlutterMethodChannel *channel;
|
|
|
CoolIjkNotifyChannel *notifyChannel;
|
|
CoolIjkNotifyChannel *notifyChannel;
|
|
|
int degree;
|
|
int degree;
|
|
|
|
|
+ CoolFlutterResult *prepareResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
|
|
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
|
|
@@ -67,8 +66,7 @@
|
|
|
NSDictionary *params = call.arguments;
|
|
NSDictionary *params = call.arguments;
|
|
|
NSString *uri = params[@"uri"];
|
|
NSString *uri = params[@"uri"];
|
|
|
NSDictionary *headers = params[@"headers"];
|
|
NSDictionary *headers = params[@"headers"];
|
|
|
- [self setDataSourceWithUri:uri headers:headers];
|
|
|
|
|
- result(@(YES));
|
|
|
|
|
|
|
+ [self setDataSourceWithUri:uri headers:headers result:[CoolFlutterResult resultWithResult:result]];
|
|
|
}
|
|
}
|
|
|
@catch (NSException *exception) {
|
|
@catch (NSException *exception) {
|
|
|
NSLog(@"Exception occurred: %@, %@", exception, [exception userInfo]);
|
|
NSLog(@"Exception occurred: %@, %@", exception, [exception userInfo]);
|
|
@@ -80,8 +78,7 @@
|
|
|
NSString *name = params[@"name"];
|
|
NSString *name = params[@"name"];
|
|
|
NSString *pkg = params[@"package"];
|
|
NSString *pkg = params[@"package"];
|
|
|
IJKFFMoviePlayerController *playerController = [self createControllerWithAssetName:name pkg:pkg];
|
|
IJKFFMoviePlayerController *playerController = [self createControllerWithAssetName:name pkg:pkg];
|
|
|
- [self setDataSourceWithController:playerController];
|
|
|
|
|
- result(@(YES));
|
|
|
|
|
|
|
+ [self setDataSourceWithController:playerController result:[CoolFlutterResult resultWithResult:result]];
|
|
|
}
|
|
}
|
|
|
@catch (NSException *exception) {
|
|
@catch (NSException *exception) {
|
|
|
NSLog(@"Exception occurred: %@, %@", exception, [exception userInfo]);
|
|
NSLog(@"Exception occurred: %@, %@", exception, [exception userInfo]);
|
|
@@ -91,8 +88,7 @@
|
|
|
NSDictionary *params = call.arguments;
|
|
NSDictionary *params = call.arguments;
|
|
|
NSString *path = params[@"path"];
|
|
NSString *path = params[@"path"];
|
|
|
IJKFFMoviePlayerController *playerController = [self createControllerWithPath:path];
|
|
IJKFFMoviePlayerController *playerController = [self createControllerWithPath:path];
|
|
|
- [self setDataSourceWithController:playerController];
|
|
|
|
|
- result(@(YES));
|
|
|
|
|
|
|
+ [self setDataSourceWithController:playerController result:[CoolFlutterResult resultWithResult:result]];
|
|
|
} else if ([@"seekTo" isEqualToString:call.method]) {
|
|
} else if ([@"seekTo" isEqualToString:call.method]) {
|
|
|
NSDictionary *params = call.arguments;
|
|
NSDictionary *params = call.arguments;
|
|
|
double target = [params[@"target"] doubleValue];
|
|
double target = [params[@"target"] doubleValue];
|
|
@@ -150,10 +146,10 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (void)setDataSourceWithController:(IJKFFMoviePlayerController *)ctl {
|
|
|
|
|
|
|
+- (void)setDataSourceWithController:(IJKFFMoviePlayerController *)ctl result:(CoolFlutterResult *)result {
|
|
|
if (ctl) {
|
|
if (ctl) {
|
|
|
controller = ctl;
|
|
controller = ctl;
|
|
|
- [self prepare];
|
|
|
|
|
|
|
+ [self prepare:result];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -221,7 +217,7 @@
|
|
|
return options;
|
|
return options;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (void)setDataSourceWithUri:(NSString *)uri headers:(NSDictionary *)headers {
|
|
|
|
|
|
|
+- (void)setDataSourceWithUri:(NSString *)uri headers:(NSDictionary *)headers result:(CoolFlutterResult *)result {
|
|
|
IJKFFOptions *options = [self createOption];
|
|
IJKFFOptions *options = [self createOption];
|
|
|
if (headers) {
|
|
if (headers) {
|
|
|
NSMutableString *headerString = [NSMutableString new];
|
|
NSMutableString *headerString = [NSMutableString new];
|
|
@@ -234,7 +230,7 @@
|
|
|
}
|
|
}
|
|
|
controller = [[IJKFFMoviePlayerController alloc] initWithContentURLString:uri withOptions:options];
|
|
controller = [[IJKFFMoviePlayerController alloc] initWithContentURLString:uri withOptions:options];
|
|
|
|
|
|
|
|
- [self prepare];
|
|
|
|
|
|
|
+ [self prepare:result];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)setDegree:(int)d {
|
|
- (void)setDegree:(int)d {
|
|
@@ -242,7 +238,8 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-- (void)prepare {
|
|
|
|
|
|
|
+- (void)prepare:(CoolFlutterResult *)result {
|
|
|
|
|
+ prepareResult = result;
|
|
|
[controller prepareToPlay];
|
|
[controller prepareToPlay];
|
|
|
if (displayLink) {
|
|
if (displayLink) {
|
|
|
displayLink.paused = YES;
|
|
displayLink.paused = YES;
|
|
@@ -258,6 +255,15 @@
|
|
|
notifyChannel.infoDelegate = self;
|
|
notifyChannel.infoDelegate = self;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)onLoadStateChange {
|
|
|
|
|
+// IJKMPMovieLoadState loadState = controller.loadState;
|
|
|
|
|
+ if (prepareResult) {
|
|
|
|
|
+ [prepareResult replyResult:@YES];
|
|
|
|
|
+ }
|
|
|
|
|
+ prepareResult = nil;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
- (IJKFFMoviePlayerController *)createControllerWithAssetName:(NSString *)assetName pkg:(NSString *)pkg {
|
|
- (IJKFFMoviePlayerController *)createControllerWithAssetName:(NSString *)assetName pkg:(NSString *)pkg {
|
|
|
NSString *asset;
|
|
NSString *asset;
|
|
|
if (!pkg) {
|
|
if (!pkg) {
|