Commit 190be3bf6414bd6b2dcd015b841a25bbc22a0739

Authored by 梁星国
1 parent 033d5069

去掉废弃代码,更改路径,取得Bundle图片,添加依赖

CNLiveAVCamera/Classes/XFCameraController.h
@@ -70,6 +70,6 @@ typedef void(^ZXShootCompletionBlock)(PHAsset *asset,NSURL *videoUrl, CGFloat vi @@ -70,6 +70,6 @@ typedef void(^ZXShootCompletionBlock)(PHAsset *asset,NSURL *videoUrl, CGFloat vi
70 @property (nonatomic, assign) BOOL isNoCanTakePhoto;// 当前是否可以拍照 70 @property (nonatomic, assign) BOOL isNoCanTakePhoto;// 当前是否可以拍照
71 71
72 //zl__会话ID,用于存储拍摄的视频 72 //zl__会话ID,用于存储拍摄的视频
73 -@property (nonatomic ,strong) NSString *conversationId; 73 +@property (nonatomic ,copy) NSString *outPutPath;
74 74
75 @end 75 @end
CNLiveAVCamera/Classes/XFCameraController.m
@@ -1450,13 +1450,29 @@ typedef void(^PropertyChangeBlock)(AVCaptureDevice *captureDevice); @@ -1450,13 +1450,29 @@ typedef void(^PropertyChangeBlock)(AVCaptureDevice *captureDevice);
1450 1450
1451 #pragma mark - TODO: 存储路径 1451 #pragma mark - TODO: 存储路径
1452 1452
1453 -// if (self.conversationId) {  
1454 -// return [CNLiveBusinessTools newChatFilePathByUserId:self.conversationId];  
1455 -// }  
1456 -// return [CNLiveBusinessTools chatFilePathByUserId:[IMAPlatform sharedInstance].host.userId];  
1457 -  
1458 - return [self chatFilePathByName:@"相册"]; 1453 + if (self.outPutPath) {
  1454 + return [self checkFilePath:self.outPutPath];
  1455 + }
  1456 + return [self chatFilePathByName:@"相机"];
  1457 +
  1458 +}
1459 1459
  1460 +- (nullable NSString *)checkFilePath:(NSString *)path {
  1461 +
  1462 + NSFileManager *fileManager = [NSFileManager defaultManager];
  1463 +
  1464 + BOOL isDir = NO;
  1465 +
  1466 + // fileExistsAtPath 判断一个文件或目录是否有效,isDirectory判断是否一个目录
  1467 + BOOL existed = [fileManager fileExistsAtPath:path isDirectory:&isDir];
  1468 +
  1469 + if ( !(isDir == YES && existed == YES) ) {
  1470 +
  1471 + return [self chatFilePathByName:@"相机"];
  1472 + }
  1473 +
  1474 + return path;
  1475 +
1460 } 1476 }
1461 1477
1462 //用户ID 1478 //用户ID
Example/CNLiveAVCamera/CNLiveViewController.m
@@ -33,7 +33,24 @@ @@ -33,7 +33,24 @@
33 { 33 {
34 XFCameraController *cameraController = [[XFCameraController alloc] init]; 34 XFCameraController *cameraController = [[XFCameraController alloc] init];
35 cameraController.isCanShootVideo = YES; 35 cameraController.isCanShootVideo = YES;
36 - cameraController.conversationId = @""; 36 + NSString *tempName = [NSString stringWithFormat:@"%@/",@"name"];
  37 +
  38 + NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:tempName];
  39 +
  40 + NSFileManager *fileManager = [NSFileManager defaultManager];
  41 +
  42 + BOOL isDir = NO;
  43 +
  44 + // fileExistsAtPath 判断一个文件或目录是否有效,isDirectory判断是否一个目录
  45 + BOOL existed = [fileManager fileExistsAtPath:filePath isDirectory:&isDir];
  46 +
  47 + if ( !(isDir == YES && existed == YES) ) {
  48 +
  49 + // 在 temp 目录下创建一临时文件
  50 + [fileManager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
  51 + }
  52 +
  53 + cameraController.outPutPath = filePath;
37 54
38 __weak XFCameraController *weakCameraController = cameraController; 55 __weak XFCameraController *weakCameraController = cameraController;
39 __weak typeof(self) weakSelf = self; 56 __weak typeof(self) weakSelf = self;
Example/Podfile
@@ -7,13 +7,13 @@ platform :ios, '9.0' @@ -7,13 +7,13 @@ platform :ios, '9.0'
7 7
8 target 'CNLiveAVCamera_Example' do 8 target 'CNLiveAVCamera_Example' do
9 pod 'CNLiveAVCamera', :path => '../' 9 pod 'CNLiveAVCamera', :path => '../'
  10 +
10 pod 'Masonry', '~> 1.0.2' 11 pod 'Masonry', '~> 1.0.2'
11 pod 'CNLiveBaseKit' 12 pod 'CNLiveBaseKit'
12 pod 'QMUIKit','~> 3.1.7' 13 pod 'QMUIKit','~> 3.1.7'
13 pod 'CNLiveBusinessTools' 14 pod 'CNLiveBusinessTools'
14 pod 'CNLiveCommonCategory' 15 pod 'CNLiveCommonCategory'
15 16
16 -  
17 target 'CNLiveAVCamera_Tests' do 17 target 'CNLiveAVCamera_Tests' do
18 inherit! :search_paths 18 inherit! :search_paths
19 19