Created
April 15, 2012 16:06
-
-
Save domkck/2393596 to your computer and use it in GitHub Desktop.
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
//Create an instance of MPMusicPlayerController | |
MPMusicPlayerController* myPlayer = [MPMusicPlayerController iPodMusicPlayer]; | |
//Create a query that will return all songs by The Beatles grouped by album | |
MPMediaQuery* query = [MPMediaQuery songsQuery]; | |
[query addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:@"The Beatles" forProperty:MPMediaItemPropertyArtist comparisonType:MPMediaPredicateComparisonEqualTo]]; | |
[query setGroupingType:MPMediaGroupingAlbum]; | |
//Pass the query to the player | |
[myPlayer setQueueWithQuery:query]; | |
//Start playing and set a label text to the name and image to the cover art of the song that is playing | |
[myPlayer play]; | |
someLabel.text = [myPlayer.nowPlayingItem valueForProperty:MPMediaItemPropertyTitle]; | |
someImageView.image = [myPlayer.nowPlayingItem valueForProperty:MPMediaItemPropertyArtwork]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment