Cover by Alasdair Allan

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

O'Reilly logo

Media Playback

Just as it has done for images with the UIImagePickerController class (see The Image Picker View Controller in Chapter 6) and for email with the MFMailComposeViewController class (see Sending Email in Chapter 7), Apple has provided a standard way to select and play back iPod media inside your own application.

Warning

The MPMediaPickerController and associated classes make use of the iPod library; this is not present in iPhone Simulator and will work correctly only on the device itself.

However, things are a little bit more complicated than the two previous cases; here we use an MPMediaPickerController that, via the MPMediaPickerControllerDelegate protocol, returns an MPMediaItemCollection object containing the media items the user has selected, and that can be played using an MPMusicPlayerController object.

These classes are provided by the Media Player framework; if you want to use them, you must add the Media Player framework to your project by right-clicking the Frameworks group in Groups & Files and selecting AddExisting Frameworks.

Let’s reuse the Prototype application. Open the Finder and navigate to the location where you saved the Prototype project. Right-click on the folder containing the project files and select Duplicate; a folder called Prototype copy will be created containing a duplicate of the project. Rename the folder PrototypePlayer, and just as we did in Chapter 7, prune the application down to the stub with the Go! button and associated pushedGo:

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