O'Reilly logo

Cocos2d for iPhone 1 Game Development Cookbook by Nathan Burba

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

Using the iPod music library

Sometimes a user might want to substitute a musical track from his or her personal collection into the background of your game. In this example, we will create a simple music player that can load songs, albums, and playlists from the iPod music library on the device.

Using the iPod music library

Getting ready

Please refer to the project RecipeCollection02 for full working code of this recipe.

How to do it...

Link the MediaPlayer framework to your project. Now, execute the following code:

#import <MediaPlayer/MediaPlayer.h> #import "AppDelegate.h" @interface Ch6_iPodLibrary : Recipe <MPMediaPickerControllerDelegate> { /* CODE OMITTED */ } @implementation ...

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