In this section, we will deal with videos instead of audio files. Playing videos is one of the most common tasks in iOS apps to play movies, shows, ads, or even tutorials for your app. We will look at the various ways of playing videos and how can you play a video in the picture in picture mode for iPad multitasking.
We will use some sample video files from http://www.sample-videos.com/, which has a huge list of different sizes, resolutions, and formats of videos that you can use in testing, and all of them are free.
Perform the following steps to add a video:
Let's, as usual, create a new Xcode project with the Single View Application template called
PlayingWithVideos
.For the demo app, we have downloaded the 1280 * 720 (5 MB) file to use in testing.
We will use
AVPlayerViewController
to display the video file. To embed a view controller...