Programmatic Picker

Often, it might be required to provide a more customized music selection option to a user. This might include creating a custom music selection interface or automatically searching for an artist or album. In this section the steps necessary to provide programmatic music selection are discussed.

To retrieve songs without using the MPMediaPickerController, a new instance of MPMediaQuery needs to be allocated and initialized. The MPMediaQuery functions as a store that references a number of MPMediaItems, each of which represents a single song or audio track to be played.

The sample app provides two methods that implement an MPMediaQuery. The first method, playRandomSongAction:, will find a single random track from the user’s ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK 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.