Created
August 11, 2014 20:38
-
-
Save romaonthego/c1de223685acbc249da7 to your computer and use it in GitHub Desktop.
Music player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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