2009-12-16 16 views
11

Apple a publié access to the iPod Library dans l'iPhone SDK 3.0 et je me demande s'il est maintenant possible de comprendre quelle chanson est en cours de lecture? Titre, Artiste, Album suffit. Exemple: L'utilisateur ouvre une application et l'application peut savoir quelle chanson joue en arrière-plan.Sur iPhone: découvrez quelle chanson joue actuellement? (dans le lecteur de musique iPod)

Quelqu'un a-t-il déjà eu cette expérience?

Merci beaucoup!

+0

Cela a déjà répondu ici sur le SO: [. IPhone sdk - accès à l'information de la chanson en cours par le biais d'une application] (http://stackoverflow.com/questions/741847/iphone-sdk-accessing-current-song -information-through-an-app) –

Répondre

24
MPMediaItem * song = [[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem]; 
NSString * title = [song valueForProperty:MPMediaItemPropertyTitle]; 
NSString * album = [song valueForProperty:MPMediaItemPropertyAlbumTitle]; 
NSString * artist = [song valueForProperty:MPMediaItemPropertyArtist]; 
+0

merci ben, vous êtes génial! –

+0

Remarque: vous devez d'abord inclure MediaPlayer.framework. – Mahouk