【问题标题】:On iPhone: Find out what song is currently playing? (in the iPod music player) [duplicate]在 iPhone 上:找出当前正在播放的歌曲? (在 iPod 音乐播放器中)[重复]
【发布时间】:2010-12-27 09:12:59
【问题描述】:

Apple 在 iPhone SDK 3.0 中发布了access to the iPod Library,我想知道现在是否可以了解当前正在播放的歌曲?标题,艺术家,专辑就足够了。示例:用户打开一个应用程序,该应用程序可以知道在后台播放的是哪首歌。

有人有这方面的经验吗?

非常感谢!

【问题讨论】:

标签: iphone objective-c ipod


【解决方案1】:
MPMediaItem * song = [[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem];
NSString * title   = [song valueForProperty:MPMediaItemPropertyTitle];
NSString * album   = [song valueForProperty:MPMediaItemPropertyAlbumTitle];
NSString * artist  = [song valueForProperty:MPMediaItemPropertyArtist];

【讨论】:

  • 谢谢你,你太棒了!
  • 注意:您需要先包含 MediaPlayer.framework。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多