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

commit

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