PLAYING VIDEO ON THE IPHONE
Playing videos is one of the most commonly performed tasks on the iPhone. Prior to iOS 4 for the iPhone, all videos had to be played full-screen. However, starting with iOS 4, this rule has been relaxed; you can now embed videos within your iPhone applications. This makes it possible for you to embed more than one video in any View window. This section shows you how to enable video playback in your iPhone applications.
TRY IT OUT: Enabling Video Playback
- Using Xcode, create a new Single View Application (iPhone) project and name it PlayVideo. You will also use the project name as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
- Drag a sample video into the Supporting Files folder of your Xcode project (see Figure 13-11).
- Double-click on the project name in Xcode and select the PlayVideo target. Select the Build Phases tab on the right and expand the section Link Binary With Libraries (3 items). Click the “+” button (see Figure 13-12).
- Select MediaPlayer.framework to add it to your project (see Figure 13-13).
- In the PlayVideoViewController.h file, code the following ...