Skip to content

Instantly share code, notes, and snippets.

@betzerra
Created October 4, 2012 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betzerra/3830789 to your computer and use it in GitHub Desktop.
Save betzerra/3830789 to your computer and use it in GitHub Desktop.
Get a NSString with current song's title and artist
-(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