Commit a4dd2854 authored by 林生雨's avatar 林生雨

commit

parent e751423d
...@@ -292,7 +292,6 @@ ...@@ -292,7 +292,6 @@
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="3" y="23" width="1440" height="811" extended-state="6" /> <frame x="3" y="23" width="1440" height="811" extended-state="6" />
<editor active="true" />
<layout> <layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.19742489" /> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.19742489" />
<window_info id="Captures" order="1" side_tool="true" /> <window_info id="Captures" order="1" side_tool="true" />
......
...@@ -2,22 +2,10 @@ ...@@ -2,22 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>wwww</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>wwww</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>ww说啥</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>sm说啥</string>
<key>NSAppleMusicUsageDescription</key>
<string>不知道说啥</string>
<key>NSCameraUsageDescription</key> <key>NSCameraUsageDescription</key>
<string>照相机</string> <string>照相机</string>
<key>NSContactsUsageDescription</key> <key>NSContactsUsageDescription</key>
<string>contactsDesciption</string> <string>contactsDesciption</string>
<key>NSMicrophoneUsageDescription</key>
<string>麦克风</string>
<key>NSPhotoLibraryAddUsageDescription</key> <key>NSPhotoLibraryAddUsageDescription</key>
<string>相册11</string> <string>相册11</string>
<key>NSPhotoLibraryUsageDescription</key> <key>NSPhotoLibraryUsageDescription</key>
......
...@@ -69,11 +69,19 @@ NSString *cacheDirectory; ...@@ -69,11 +69,19 @@ NSString *cacheDirectory;
ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus]; ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];
NSString *mediaType = AVMediaTypeVideo; //读取媒体类型 NSString *mediaType = AVMediaTypeVideo; //读取媒体类型
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType]; //读取设备授权状态 AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType]; //读取设备授权状态
if(author == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) { NSLog(@"STATE %d",authStatus);
if(author ==AVAuthorizationStatusAuthorized){
NSLog(@"相机可用");
long temp=self.resultKey;
[self scanPhone:temp];
}
else if(author == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) {
NSLog(@"没给权限!!!"); NSLog(@"没给权限!!!");
NSString *errorStr = @"应用相机权限受限,请在iPhone的“设置-隐私-相机”选项中,允许好享玩访问你的相机。"; NSString *errorStr = @"应用相机权限受限,请在iPhone的“设置-隐私-相册”选项中,允许好享玩访问你的相册。";
[self showToast:errorStr inView:[UIApplication sharedApplication].windows.lastObject]; UIAlertView * alert = [[UIAlertView alloc]initWithTitle:nil message:errorStr delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
}else if(author == AVAuthorizationStatusNotDetermined){ [alert show];
}else {
NSLog(@"HERRRRRRRR");
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if(status == PHAuthorizationStatusAuthorized) { if(status == PHAuthorizationStatusAuthorized) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
...@@ -84,36 +92,42 @@ NSString *cacheDirectory; ...@@ -84,36 +92,42 @@ NSString *cacheDirectory;
} else { } else {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
// 用户点击 不允许访问 // 用户点击 不允许访问
NSString *errorStr = @"应用相机权限受限,请在iPhone的“设置-隐私-相册”选项中,允许好享玩访问你的相册。";
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:nil message:errorStr delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
NSLog(@"被拒绝 TODO!!"); NSLog(@"被拒绝 TODO!!");
}); });
} }
}]; }];
}else{
NSLog(@"相机可用");
long temp=self.resultKey;
[self scanPhone:temp];
} }
} else if([@"native_camera" isEqualToString:call.method]){ } else if([@"native_camera" isEqualToString:call.method]){
self.nativeCameraKey=self.resultKey; self.nativeCameraKey=self.resultKey;
NSString *mediaType = AVMediaTypeVideo;//读取媒体类型 NSString *mediaType = AVMediaTypeVideo;//读取媒体类型
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//读取设备授权状态 AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//读取设备授
if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){ if(authStatus ==AVAuthorizationStatusAuthorized){
NSLog(@"相机可用");
dispatch_async(dispatch_get_main_queue(), ^{
[self nativeCamera];
});
}
else if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
NSString *errorStr = @"应用相机权限受限,请在iPhone的“设置-隐私-相机”选项中,允许好享玩访问你的相机。"; NSString *errorStr = @"应用相机权限受限,请在iPhone的“设置-隐私-相机”选项中,允许好享玩访问你的相机。";
NSLog(@"相机不可用"); NSLog(@"相机不可用");
[self showToast:errorStr inView:[UIApplication sharedApplication].windows.lastObject];
}else if(authStatus == AVAuthorizationStatusNotDetermined){ UIAlertView * alert = [[UIAlertView alloc]initWithTitle:nil message:errorStr delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
}else {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if(granted){ if(granted){
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self nativeCamera]; [self nativeCamera];
}); });
}else{
NSString *errorStr = @"应用相机权限受限,请在iPhone的“设置-隐私-相册”选项中,允许好享玩访问你的相册。";
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:nil message:errorStr delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
} }
}]; }];
}else {
NSLog(@"相机可用");
dispatch_async(dispatch_get_main_queue(), ^{
[self nativeCamera];
});
} }
}else if([@"quit_page" isEqualToString:call.method]){ }else if([@"quit_page" isEqualToString:call.method]){
self.quitPage=true; self.quitPage=true;
...@@ -374,54 +388,54 @@ NSString *cacheDirectory; ...@@ -374,54 +388,54 @@ NSString *cacheDirectory;
[video setImagePre:assets]; [video setImagePre:assets];
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES]; [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES];
// if([fileManager fileExistsAtPath:tempTake]){ // if([fileManager fileExistsAtPath:tempTake]){
// NSMutableDictionary *dict=[[NSMutableDictionary alloc] init]; // NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
// [dict setObject:path forKey:@"path"]; // [dict setObject:path forKey:@"path"];
// [dict setObject:tempTake forKey:@"realImagePath"]; // [dict setObject:tempTake forKey:@"realImagePath"];
// [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict]; // [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict];
// }else{ // }else{
// dispatch_async(queue, ^{ // dispatch_async(queue, ^{
// CFAbsoluteTime start=CFAbsoluteTimeGetCurrent(); // CFAbsoluteTime start=CFAbsoluteTimeGetCurrent();
// int picWidth=[assets pixelWidth]; // int picWidth=[assets pixelWidth];
// int picHeight=[assets pixelHeight]; // int picHeight=[assets pixelHeight];
// float tempScareSize=1; // float tempScareSize=1;
// float limit=1024.0; // float limit=1024.0;
// float max=MAX(picWidth, picHeight); // float max=MAX(picWidth, picHeight);
// if(max>limit){ // if(max>limit){
// tempScareSize=limit/max; // tempScareSize=limit/max;
// } // }
// CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize); // CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize);
// __block bool isResult=false; // __block bool isResult=false;
// [[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { // [[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
// if(isResult){ // if(isResult){
// return ; // return ;
// } // }
// isResult=true; // isResult=true;
// @autoreleasepool{ // @autoreleasepool{
// NSData *data = UIImageJPEGRepresentation(result, 0.7) ; // NSData *data = UIImageJPEGRepresentation(result, 0.7) ;
// [data writeToFile:tempTake atomically:YES]; // [data writeToFile:tempTake atomically:YES];
// // result=nil; // // result=nil;
// // data=nil; // // data=nil;
// } // }
// NSMutableDictionary *dict=[[NSMutableDictionary alloc] init]; // NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
// [dict setObject:path forKey:@"path"]; // [dict setObject:path forKey:@"path"];
// [dict setObject:tempTake forKey:@"realImagePath"]; // [dict setObject:tempTake forKey:@"realImagePath"];
// dispatch_async(dispatch_get_main_queue(), ^{ // dispatch_async(dispatch_get_main_queue(), ^{
// NSLog(@"压缩预览图片耗时:%f ms Temp路径%@",(CFAbsoluteTimeGetCurrent()-start)*1000,tempTake); // NSLog(@"压缩预览图片耗时:%f ms Temp路径%@",(CFAbsoluteTimeGetCurrent()-start)*1000,tempTake);
// [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict]; // [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict];
// }); // });
// }]; // }];
// }); // });
// } // }
}else if ([[self.takePhotoMap allKeys] containsObject:path]){ }else if ([[self.takePhotoMap allKeys] containsObject:path]){
MyPreviewController* video=[[MyPreviewController alloc] init]; MyPreviewController* video=[[MyPreviewController alloc] init];
[viewController presentViewController:video animated:YES completion:nil]; [viewController presentViewController:video animated:YES completion:nil];
[video setImagePrePath:self.takePhotoMap[path]]; [video setImagePrePath:self.takePhotoMap[path]];
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES]; [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES];
// NSMutableDictionary *dict=[[NSMutableDictionary alloc] init]; // NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
// [dict setObject:path forKey:@"path"]; // [dict setObject:path forKey:@"path"];
// [dict setObject:self.takePhotoMap[path] forKey:@"realImagePath"]; // [dict setObject:self.takePhotoMap[path] forKey:@"realImagePath"];
// [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict]; // [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :dict];
}else{ }else{
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :nil]; [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :nil];
} }
...@@ -432,20 +446,20 @@ NSString *cacheDirectory; ...@@ -432,20 +446,20 @@ NSString *cacheDirectory;
PHAsset * assets=self.scanMap[path]; PHAsset * assets=self.scanMap[path];
MyPlayerViewController* video=[[MyPlayerViewController alloc] init]; MyPlayerViewController* video=[[MyPlayerViewController alloc] init];
[viewController presentViewController:video animated:YES completion:nil]; [viewController presentViewController:video animated:YES completion:nil];
// video.player= [[AVPlayeralloc]initWithURL:url]; // video.player= [[AVPlayeralloc]initWithURL:url];
[video playMovie:assets]; [video playMovie:assets];
[[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES]; [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES];
// PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init]; // PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
// options.version = PHImageRequestOptionsVersionCurrent; // options.version = PHImageRequestOptionsVersionCurrent;
// options.networkAccessAllowed = true; // options.networkAccessAllowed = true;
// options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic; // options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
// [[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) { // [[PHImageManager defaultManager]requestAVAssetForVideo:assets options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
// AVURLAsset *urlAsset = (AVURLAsset *)asset; // AVURLAsset *urlAsset = (AVURLAsset *)asset;
// AVPlayerViewController* video=[[AVPlayerViewController alloc] init]; // AVPlayerViewController* video=[[AVPlayerViewController alloc] init];
// [viewController presentViewController:video animated:YES completion:nil]; // [viewController presentViewController:video animated:YES completion:nil];
// [video playMovie:urlAsset.URL]; // [video playMovie:urlAsset.URL];
// [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES]; // [[ResultManager sharedSingleton] resultSuccess:[NSNumber numberWithLong:resultTemp] :@YES];
// }]; // }];
} }
}else{ }else{
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment