iOS 使用镜头捕捉视频

- (void)takeVideo {
    UIImagePickerController *camera = [[UIImagePickerController alloc] init];
    NSArray *availableTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
    camera.mediaTypes = availableTypes;
    camera.sourceType = UIImagePickerControllerSourceTypeCamera;
    camera.delegate = self;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    //UIImage *image = info[UIImagePickerControllerOriginalImage];

    // 不同于获取图片,我们从Delegate中取得的是所拍摄视频的URL
    NSURL *videoURL = info[UIImagePickerControllerReferenceURL];

    //拷贝所拍视频到用户相册中,并且删除临时目录中的视频文件
    if (videoURL) {
        if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([videoURL path])) {
            UISaveVideoAtPathToSavedPhotosAlbum([videoURL path], nil, nil, nil);
            [[NSFileManager defaultManager] removeItemAtPath:[videoURL path] error:nil];
        }
    }
}

github: https://github.com/lnmcc/Homepwne.git