Skip to content

Instantly share code, notes, and snippets.

@romaonthego
Created August 11, 2014 20:38
Show Gist options
  • Save romaonthego/c1de223685acbc249da7 to your computer and use it in GitHub Desktop.
Save romaonthego/c1de223685acbc249da7 to your computer and use it in GitHub Desktop.
Music player
MPMusicPlayerController *controller = [MPMusicPlayerController iPodMusicPlayer];
MPMediaPropertyPredicate *artistPredicate = [MPMediaPropertyPredicate predicateWithValue:@"The Killers"
forProperty:MPMediaItemPropertyArtist
comparisonType:MPMediaPredicateComparisonContains];
MPMediaQuery *query = [[MPMediaQuery alloc] initWithFilterPredicates:[NSSet setWithArray:@[artistPredicate]]];
for (MPMediaItem *song in query.items) {
NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
NSLog(@"Song title %@", songTitle);
}
[controller setQueueWithQuery:query];
[controller play];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment