Cover by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

11.8. Editing Videos on an iOS Device

Problem

You want the user of your application to be able to edit videos straight from your application.

Solution

Use the UIVideoEditorController class. In this example, we will use this class in conjunction with an image picker controller. First we will ask the user to pick a video from her photo library. After she does, we will display an instance of the video editor controller and allow the user to edit the video she picked.

Discussion

The UIVideoEditorController in the iOS SDK allows programmers to display a video editor interface to the users of their applications. All you have to do is to provide the URL of the video that needs to be edited and then present the video editor controller as a modal view. You should not overlay the view of this controller with any other views, and you should not modify this view.

Note

Calling the presentModalViewController:animated: method immediately after calling the dismissModalViewControllerAnimated: method of a view controller will terminate your application with a runtime error. You must wait for the first view controller to be dismissed and then present the second view controller. You can take advantage of the viewDidAppear: instance method of your view controllers to detect when your view is displayed. You know at this point that any modal view controllers must have disappeared.

So let’s go ahead and declare the view controller and any necessary properties:

#import <UIKit/UIKit.h> #import <AssetsLibrary/AssetsLibrary.h> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required