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

Get Cocos2d for iPhone 1 Game Development 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.