O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

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

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

image

  1. 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.
  2. Drag a sample video into the Supporting Files folder of your Xcode project (see Figure 13-11).

    image

    FIGURE 13-11

  3. 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).

    image

    FIGURE 13-12

  4. Select MediaPlayer.framework to add it to your project (see Figure 13-13).

    FIGURE 13-13

  5. In the PlayVideoViewController.h file, code the following ...

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