In the previous post we covered how to create a simple camera app. In this post, we’re going to create a similar application but for video recording and playback.
The iOS API for recording and playing videos can be a little bit confusing for the newcomer, as there are several options available. If you just want to play a video, you can use the MediaPlayer framework, which allows us to play a video stored locally in our device, or from a remote location. However, if you need advanced features such as media asset management, media editing, track management, and others, you have to use the AVFoundation framework. This post will only cover the MediaPlayer framework.
On top of that, the MediaPlayer framework brings us two main classes to display videos or movies. If you want to display a video immediately and inline (e.g. a subview smaller than the full screen), you should use the MPMoviePlayerController. By using MPMoviePlayerController, playback occurs in a view owned by the movie player. You can incorporate a movie player’s view into a view owned by your app. On the contrary, if you want to play a full screen video, for example by presenting the video modally, you should use the MPMoviePlayerViewController class. The MPMoviePlayerViewController class is designed to present a simple view controller for displaying full-screen movies.
In this tutorial, we will explain the MPMoviePlayerController but similar concept applies to the MPMoviePlayerViewController class.