[翻译] 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 ...
随机推荐
- js便签笔记(4)——简单说说getAttributeNode()和setAttributeNode()
1.前言: 前两天写过一片<分析dom元素的特性Attribute和属性Property>,分析了特性和属性的区别.那篇文章却忽略了一个主要知识点——getAttributeNode()和 ...
- R语言-RStudio快捷键总结
一.控制台 功能 Windows & Linux Mac 移动鼠标到控制台 Ctrl+2 Ctrl+2 移动到鼠标命令编辑 Ctrl+1 Ctrl+1 控制台清屏 Ctrl+L Comm ...
- mysql 导出数据到csv文件的命令
1.导出本地数据库数据到本地文件 mysql -A service_db -h your_host -utest -ptest mysql> select * from t_apps where ...
- scanf()函数分析
首先,先来讲一下scanf的读取流程: 从键盘输入的都是字符类型(一系列的字符),scanf()的作用就是将这个字符序列转换成一个或多个指定的类型,并保存到变量中. 从键盘输入的字符序列会先缓存到键盘 ...
- Oracle数据库之PL/SQL程序基础设计
一.PL/SQL块结构 前边我们已经介绍了PL/SQL块的结构,再来回顾一下: DECLARE /* * 声明部分——定义常量.变量.复杂数据类型.游标.用户自定义异常 */ BEGIN /* * 执 ...
- es索引的RestHighLevelClient实现
java代码: import java.io.IOException; import org.apache.http.HttpHost; import org.elasticsearch.action ...
- win7下如何解决对方可以ping通我,但我ping不通对方问题
以下是在百度经验里面找到的文章:http://jingyan.baidu.com/article/6b97984da3ac851ca2b0bfe1.html 当我在虚拟机的linux系统中ping本机 ...
- [BZOJ 5072]小A的树
Description 题库链接 给你 \(n\) 个节点的一棵树,点分黑白. \(q\) 组询问,每次询问类似于"是否存在树中 \(x\) 个点的连通块恰有 \(y\) 个黑点" ...
- [转]VS 2010 : 如何开发和部署Outlook 2010插件(Add-in)
本文转自:https://www.cnblogs.com/chenxizhang/archive/2010/05/08/1730766.html 概述: 这篇文章,我将通过一个简单的例子,给大家分享一 ...
- ASPxPopupControl出现前一次弹框页面解决方法
设置关闭事件 <ClientSideEvents CloseUp="CloseUp" /> function CloseUp(s, e) { s.SetCont ...