[翻译] LLSimpleCamera

简介:

LLSimpleCamera

https://github.com/omergul123/LLSimpleCamera

 

LLSimpleCamera is a library for creating a customized camera - video recorder screens similar to snapchat's. You don't have to present the camera in a new view controller.

You can also use my LLVideoEditor library to easily edit recorded videos.

LLSimpleCamera是一个用以构造自定义照相机 - 视频录制界面的库,类似于snapchat.你不需要将当前控制器在一个新的控制器中推出来.

 

LLSimpleCamera:

  • lets you easily capture photos and record videos (finally) 让你非常简易的照相以及录制视频
  • handles the position and flash of the camera 控制照相位置或者是闪光灯
  • hides the nitty gritty details from the developer 隐藏令人恶心的实现细节
  • doesn't have to be presented in a new modal view controller, simply can be embedded inside any of your VCs. (like Snapchat) 不需要创建一个新的控制器,你可以在你的任何VC中进行显示

 

Install

pod 'LLSimpleCamera', '~> 3.0'

 

Example usage

Initialize the LLSimpleCamera

初始化LLSimpleCamera

CGRect screenRect = [[UIScreen mainScreen] bounds];

// create camera with standard settings
self.camera = [[LLSimpleCamera alloc] init];

// camera with video recording capability
self.camera =  [[LLSimpleCamera alloc] nitWithVideoEnabled:YES];

// camera with precise quality, position and video parameters.
self.camera = [[LLSimpleCamera alloc] initWithQuality:AVCaptureSessionPresetHigh
                                             position:CameraPositionBack
                                         videoEnabled:YES];
// attach to the view
[self.camera attachToViewController:self withFrame:CGRectMake(0, 0, screenRect.size.width, screenRect.size.height)];

To capture a photo:

照相:

// capture
[self.camera capture:^(LLSimpleCamera *camera, UIImage *image, NSDictionary *metadata, NSError *error) {
    if(!error) {    
        // we should stop the camera, since we don't need it anymore. We will open a new vc.
        // this very important, otherwise you may experience memory crashes
        [camera stop];

        // show the image
        ImageViewController *imageVC = [[ImageViewController alloc] initWithImage:image];
        [self presentViewController:imageVC animated:NO completion:nil];
       }
}];

To start recording a video:

开始录像:

// start recording
NSURL *outputURL = [[[self applicationDocumentsDirectory]
                     URLByAppendingPathComponent:@"test1"] URLByAppendingPathExtension:@"mov"];
[self.camera startRecordingWithOutputUrl:outputURL];

To stop recording the video:

[self.camera stopRecording:^(LLSimpleCamera *camera, NSURL *outputFileUrl, NSError *error) {
    VideoViewController *vc = [[VideoViewController alloc] initWithVideoUrl:outputFileUrl];
    [self.navigationController pushViewController:vc animated:YES];
}];

Changing the focus layer and animation:

- (void)alterFocusBox:(CALayer *)layer animation:(CAAnimation *)animation;

 

Adding the camera controls

添加摄像头控制细节

You have to add your own camera controls (flash, camera switch etc). Simply add the controls to the view where LLSimpleCamera is attached to. You can see a full camera example in the example project. Download and try it on your device.

你需要根据需求添加你想用的控制细节(闪光灯,照相机或者其他的东西).只需要将要添加的东西添加到LLSimpleCamera附着的view上.你可以在项目源码中看到一个完整的实例.

 

Stopping and restarting the camera

You should never forget to stop the camera either after the capture block is triggered, or inside somewhere -viewWillDisappear of the parent controller to make sure that the app doesn't use the camera when it is not needed. You can call -start() to reuse the camera. So it may be good idea to to place -start() inside -viewWillAppear or in another relevant method.

你要确保不要忘记在用完了摄像头后关闭相关的操作句柄.

目录
相关文章
|
Perl
pod spec lint编译时报error: include of non-modular header inside framework module
pod spec lint编译时报error: include of non-modular header inside framework module
245 1
|
6月前
|
机器学习/深度学习 人工智能 搜索推荐
底层技术大揭秘!AI智能导购如何重塑购物体验
双十一期间,淘宝内测AI助手“淘宝问问”,基于阿里通义大模型,旨在提升用户在淘宝上的商品搜索和推荐效率。该助手通过品牌推荐、兴趣商品推荐和关联问题三大板块,提供个性化购物体验。其背后采用多智能体架构,包括规划助理和商品导购助理,通过对话历史和用户输入,实现精准商品推荐。此外,文章还介绍了如何快速部署此解决方案,并探讨了其对现代购物体验的影响。
|
10月前
|
缓存
成功解决:Could not resolve dependency: npm ERR! peer vue@“^3.0.2“ from vuex@4.0.2
这篇文章讨论了在使用npm安装依赖时遇到的一个常见问题,即无法解析依赖导致的"peer dependency"冲突错误。文章提供了几种解决方法,包括清除npm缓存、删除`node_modules`文件夹和`package-lock.json`文件,然后重新尝试安装,以解决版本冲突问题。
|
安全 数据处理 量子技术
探索未来互联网:量子计算与区块链技术的融合
本文深入探讨了量子计算和区块链技术的结合如何开启互联网的未来。通过分析量子计算的原理及其对传统加密技术的挑战,以及区块链技术在数据安全和信息共享方面的优势,揭示了两者结合带来的革命性影响。文章还预测了这一技术融合对金融、医疗等行业的潜在变革,并讨论了面临的挑战及未来的发展方向。
|
9月前
|
Cloud Native 持续交付 开发者
云端之旅:探索云原生应用的构建与部署
【9月更文挑战第26天】在这篇文章中,我们将一起踏上一段激动人心的旅程,深入探讨云原生应用的构建和部署。通过实际的代码示例和详细的步骤说明,我们将揭开云原生技术的神秘面纱,展示如何利用这些技术来创建灵活、可扩展的应用。无论你是云原生领域的新手还是希望深化理解的开发者,这篇文章都将为你提供宝贵的知识和技能。
130 0
|
11月前
|
边缘计算 物联网 开发者
什么是容器Docker?
什么是容器?容器,也叫Docker,是一个开源的容器化平台,用于开发、测试和部署应用程序。通过将软件打包为标准化的单元(容器),使得应用程序可以在任何地方一致地运行,不论是在开发者的本地机器上,还是在云计算平台上。Docker容器包含了应用程序运行所需的一切,包括代码、运行时、系统工具、系统库等,从而解决了“在我这里可以正常工作,但在服务器上不行”的问题。
782 1
|
12月前
|
存储 安全 C++
UEFI vs Legacy:深入理解两种启动模式的区别
UEFI vs Legacy:深入理解两种启动模式的区别
3363 0
|
Java
JAVA练习小游戏——本地双人联机乒乓球小游戏
JAVA练习小游戏——本地双人联机乒乓球小游戏
280 0
|
存储 运维 监控
《泛娱乐行业技术服务白皮书》——三、泛娱乐典型业务架构与场景——3.2 游戏类泛娱乐——3.2.4 游戏技术服务演进
《泛娱乐行业技术服务白皮书》——三、泛娱乐典型业务架构与场景——3.2 游戏类泛娱乐——3.2.4 游戏技术服务演进
140 0
|
存储 安全 固态存储
阿里云aca考试通过率以及试题
不同于阿里云认证的其他考试,阿里云aca考试科目非常多,难度自然是比较高的,那么阿里云aca考试通过率怎么样呢?接下来为我们详细介绍阿里云aca考试通过率以及阿里云aca考试试题。
1193 0
阿里云aca考试通过率以及试题