I'm trying to play back a song referenced from a stored persistentIdentifier, but the MPMediaQuery returns 0 results if I apply a filter to it using the stored value.
My code for the not-working filtered version:
NSNumber *persistentId = [NSNumber numberWithLongLong:15991677378153886747];
MPMediaPredicate *filter = [MPMediaPropertyPredicate predicateWithValue:persistentId forProperty:MPMediaItemPropertyPersistentID];
MPMediaQuery *songQuery = [[MPMediaQuery alloc] initWithFilterPredicates:[NSSet setWithObject:filter]];
NSArray *songs = [songQuery items]; // [songs count] is zero here
Despite songs
containing a MPMediaItem which should pass through this filter, I instead get zero items returned. Check this out (done the bad way):
MPMediaQuery *songQuery = [[MPMediaQuery alloc] init];
NSArray *songs = [songQuery items];
// gives <MPConcreteMediaItem: 0x1dd4d3c0> 15991677378153886747
NSLog(@"%@", [songs objectAtIndex:5]);
// gives 15991677378153886747
NSLog(@"%@", persistentId);
What am I doing wrong? I have read the docs / sample projects and it looks like this is how one does it.