Created
October 4, 2012 00:31
-
-
Save betzerra/3830789 to your computer and use it in GitHub Desktop.
Get a NSString with current song's title and artist
This file contains hidden or 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
-(NSString *) currentSong { | |
NSString *retVal = nil; | |
MPMusicPlayerController* iPodMusicPlayer = [MPMusicPlayerController iPodMusicPlayer]; | |
MPMediaItem *mediaItem = [iPodMusicPlayer nowPlayingItem]; | |
if (mediaItem) { | |
NSString *artist = [mediaItem valueForProperty: MPMediaItemPropertyArtist]; | |
NSString *song = [mediaItem valueForProperty: MPMediaItemPropertyTitle]; | |
retVal = [NSString stringWithFormat:@"NLT: %@ - %@", song, artist]; | |
} | |
return retVal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment