Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On iPhone: Find out what song is currently playing? (in the iPod music player) [duplicate]

Apple released access to the iPod Library in the iPhone SDK 3.0 and I'm wondering if it's now possible to understand which song is currently playing? Title, Artist, Album suffices. Example: User opens an app and the app can know which song is playing in the background.

Has anyone had any experience with this?

Thanks a bunch!

like image 662
Gregor Hochmuth Avatar asked Dec 16 '09 19:12

Gregor Hochmuth


1 Answers

MPMediaItem * song = [[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem];
NSString * title   = [song valueForProperty:MPMediaItemPropertyTitle];
NSString * album   = [song valueForProperty:MPMediaItemPropertyAlbumTitle];
NSString * artist  = [song valueForProperty:MPMediaItemPropertyArtist];
like image 126
Ben S Avatar answered Nov 15 '22 12:11

Ben S