Search code examples
c#iosmpmediaquery

Retrieve all songs from the iPod library without useing MPMediaPickerController


I'm writing an iPhone app to retrieve all songs from a users iPod library on their iPhone, but I don't want to use the MPMediaPickerController. Meanwhile, I will display the songs in a custom ListView/TableView.

I've written a query to select all songs from the users iPhone:

MPMediaQuery mq = new MPMediaQuery ();
var value = NSNumber.FromInt32 ((int) MPMediaType.Music); 
var type = MPMediaItemProperty.MediaType; 
var predicate = MPMediaPropertyPredicate.PredicateWithValue (value, type);
mq.AddFilterPredicate (predicate);

How do I run this against the iPhones iPod library without having to use the MPMediaPickerController?


Solution

  • The Items property of the MPMediaQuery mq will contain the results that you'd use to populate your view.