# chRecordCamera **Repository Path**: Cyptt/ch-record-camera ## Basic Information - **Project Name**: chRecordCamera - **Description**: 相机拍摄录像 - **Primary Language**: Objective-C - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-03-31 - **Last Updated**: 2022-06-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # chRecordCamera ## 介绍 相机拍照、录像 ## 引入 pod 'CHRecordCameraSDK' ## 配置 info.plist ``` NSCameraUsageDescription 此app会在拍照等取证服务中访问您的相机权限 NSMicrophoneUsageDescription 此app会在拍照等取证服务中访问您的麦克风权限 NSPhotoLibraryAddUsageDescription 写入相册 ``` ## 使用 ``` AVCaptureVideoPreviewLayer * previewLayer = [[AVCaptureVideoPreviewLayer alloc] init]; previewLayer.frame = self.view.bounds; previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; [self.view.layer addSublayer: self.previewLayer ]; CHRecordFile * recordFile = [[CHRecordFile alloc]init]; [recordFile startPreView:previewLayer]; [recordFile startRecordFilePath:nil isSaveAblum:self.isSaveAblum successBlock:^(NSURL * _Nonnull filePath) { } failBlock:^(NSError * _Nonnull error) { }]; ``` ## 接口 ### 1.设置预览图 - 接口名 -(void)startPreView:(AVCaptureVideoPreviewLayer *)preViewLayer; - 参数 | 参数名 | 说明 | 类型 | 是否比传 | | --- | --- | --- | --- | | preViewLayer | 预览图 | AVCaptureVideoPreviewLayer | 是 | ### 2.开始拍摄/录像 - 接口名 -(void)startRecordFilePath:(nullable NSString *)filePath isSaveAblum:(BOOL)isSaveAblum successBlock:(void (^ _Nonnull)(NSURL * filePath))successBlock failBlock:(void (^ _Nonnull)(NSError * error))failBlock; - 参数名 | 参数名 | 说明 | 类型 | 是否比传 | | --- | --- | --- | --- | | filePath | 文件路径传则用sdk默认的 | NSString | 否 | | isSaveAblum | 是否保持相册yes 保存 | BOOL | 是 | | successBlock | 成功回调 | block | 是 | | failBlock | 失败回调 | block | 是 | ### 3.停止录制 - 接口名 -(void)stop; ### 4.开启闪光灯 - 参数名 -(void)openFlashSuccessBlock:(void (^ _Nonnull)(BOOL isSuccess))successBlock failBlock:(void (^ _Nonnull)(NSString * errMsg))failBlock; - 参数 | 参数名 | 说明 | 类型 | 是否比传 | | --- | --- | --- | --- | | successBlock | 成功回调 | block | 是 | | failBlock | 失败回调 | block | 是 | ### 5.关闭闪光灯 - 接口名 -(void)closeFlash; ### 6.翻转摄像头 -(void)transferCapture;