UIVideoEditorController的使用
来源:互联网 发布:vue.js省市区三级联动 编辑:程序博客网 时间:2024/05/17 22:22
UIVideoEditorController是一个视频编辑器,通过系统提供的UI界面来剪切视频或者降低视频的画质.UIVideoEditorController对象处理用户的交互并且提供把编辑后的视频的文件系统路径提供给UIVideoEditorControllerDelegate对象.
UIVideoEditorController只支持能够支持视频编辑的设备.
UIVideoEditorController和UIImagePickerController的主要区别是前者能提供视频的编辑,后者主要用于录像或者视频的选择.
实现代码:
<pre name="code" class="objc"><span style="font-family:Times New Roman;font-size:14px;">//遵守协议class ViewController: UIViewController, UIVideoEditorControllerDelegate, UINavigationControllerDelegate { var editVideoViewController:UIVideoEditorController! @IBAction func editVideoTapped(sender: AnyObject) { //取到Video的资源 let videoPath = NSBundle.mainBundle().pathForResource("show", ofType: "mov"); //创建之前要确定是否能够打开视频文件,如果能打开才创建UIVideoEditController if UIVideoEditorController.canEditVideoAtPath(videoPath!) { //创建UIVideoEditController editVideoViewController = UIVideoEditorController() //设置delegate editVideoViewController.delegate = self //设置要编辑的视频地址 editVideoViewController.videoPath = videoPath! //设置视频最长时间 editVideoViewController.videoMaximumDuration = 30 //设置视频的画质(如果TypeHigh,则画质不变) editVideoViewController.videoQuality = .TypeHigh //present UIVideoEditController presentViewController(editVideoViewController, animated: true, completion: {}) } } //UIVideoEditorController自己不会主动小时,所以delegate的回调方法的一个主要作用是消除UIVideoEditorController, //编辑成功后的Video被保存在沙盒的临时目录中 func videoEditorController(editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) { print("editedVideopath = \(editedVideoPath)") dismissViewControllerAnimated(true, completion: {}) } //编辑失败后调用的方法 func videoEditorController(editor: UIVideoEditorController, didFailWithError error: NSError) { print("error=\(error.description)") dismissViewControllerAnimated(true, completion: {}) } //编辑取消后调用的方法 func videoEditorControllerDidCancel(editor: UIVideoEditorController) { dismissViewControllerAnimated(true, completion: {}) }}</span>
效果图:
0 0
- UIVideoEditorController的使用
- UIVideoEditorController
- GUID使用的使用
- ${}的使用
- 的使用
- @[],@()的使用
- ->的使用
- +、-、*、/、%的使用
- &&的使用
- %:的使用
- Makefile中使用$$的使用
- Makefile中使用$$的使用
- Red5的使用--使用日志
- prefernce的使用具体使用
- 【工具使用】git 的使用
- 关于使用AsyncTaskLoader的使用
- 使用CABasicAnimation的基本使用
- 使用RocketMQ的客户端使用
- Quartz 项目应用笔记
- 快速学习html、css的经典笔记
- 在Oracle中写出性能优良的SQL语句
- 使用IO库读取文件
- shell编程之if判断的总结
- UIVideoEditorController的使用
- hdu4336-----Card Collector
- Eclipse常用的10个快捷键
- visual studio 2013 快捷键大全、VS2013常用快捷键
- 使用命令对APK包进行签名
- Touch事件总结
- Linux下通配符总结
- mybatis入门
- Android adb 查看正在运行的程序 杀进程后守护进程保持