[翻译] 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.
你要确保不要忘记在用完了摄像头后关闭相关的操作句柄.
[翻译] LLSimpleCamera的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- R语言---- 数据的基本运算
一.基本运算符号 1.基本数学计算 +.-.*./.^.%%(求模).%/%(整除)注意:求模运算两边若为小数,则整数和小数部分分别求模.例:5.6%%2.2 2.比较运算 >.<.> ...
- Java的Date类与Calendar
一.Date类 在JDK1.0中,Date类是唯一的一个代表时间的类,但是由于Date类不便于实现国际化,所以从JDK1.1版本开始,推荐使用Calendar类进行时间和日期处理.这里简单介绍一下Da ...
- 在你的 Rails App 中开启 ETag 加速页面载入同时节省资源
转自http://huacnlee.com/blog/use-etag-in-your-rails-app-to-speed-up-loading/ 什么是 ETag 网上关于 ETag 的解释有很多 ...
- unity简单动画实现
1:创建一个Sprite Render (player)的动画对象并添加脚本Player,点击主菜单“Window(视窗)→Animation(动画窗口)”Animation面板(选中需要动画的对象) ...
- c#读取html文件内容替换之后再写入
string sss = File.ReadAllText("E:\\FM\\Mall\\MallSGWeb\\MallSGWeb\\MALL_simple\\File\\11111.htm ...
- 使用Visual Studio 2010打造C语言编译器
相信学习C语言的同学们一直在为自己的windows7不能用vc 6.0而烦恼着.或许有的电脑能使用上,但绝大多数是不能的,而且会出现软件不能兼容的提醒.其实大家都不需要再使用vc6.0了,因为软件更新 ...
- mybatis在oracle中的分页扩展
applicationContext.xml <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlS ...
- clipboard.js实现复制功能
项目地址:https://github.com/zenorocha/clipboard.js 现代化的“复制到剪切板”插件.不包含 Flash.gzip 压缩后仅 3kb. 为什么使用它 复制文字到剪 ...
- Java使用Redisson分布式锁实现原理
本篇文章摘自:https://www.jb51.net/article/149353.htm 由于时间有限,暂未验证 仅先做记录.有大家注意下哈(会尽快抽时间进行验证) 1. 基本用法 添加依赖 &l ...
- 地址解析协议ARP,网络层协议IP、ICMP协议
分析所用软件下载:Wireshark-win32-1.10.2.exe 阅读导览 1. 分析并且应用ARP协议 2.分析IP协议 3.分析ICMP协议 1.分析arp报文的格式与内容 (1)ping ...