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

僤鯓⒐⒋嵵緔 提交于 2019-11-26 19:16:29

问题


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!


回答1:


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


来源:https://stackoverflow.com/questions/1917014/on-iphone-find-out-what-song-is-currently-playing-in-the-ipod-music-player

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!