How to do it...

Perform the following steps to add a video:

  1. Let's, as usual, create a new Xcode project with the Single View Application template called PlayingWithVideos.
  2. For the demo app, we have downloaded the 1280 * 720 (5 MB) file to use in testing.
Ensure that you have copied the video file in the Xcode project, as we will read the file from the main bundle.
  1. We will use AVPlayerViewController to display the video file. To embed a view controller in the ViewController screen that we have, we will use the Container view that we talked about earlier.
  2. Go to Object Library and drag a Container view with the following constraints:
 Container.leading = Superview.leading Container.trailing = Superview.trailing Container.height = 250 Container.top ...

Get iOS Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.