【发布时间】:2013-12-30 08:36:37
【问题描述】:
感谢您注意到这个问题。我想做一些关于音乐推荐的事情,我现在正在做的是利用MPNowPlayingInfoCenter的nowPlayingInfo,像这样:
NSDictionary *metaData = [[MPNowPlayingInfoCenter defaultCenter] nowPlayingInfo];
NSString *songTitle = metaData[MPMediaItemPropertyTitle];
NSString *albumnTitle = metaData[MPMediaItemPropertyAlbumTitle];
NSString *artist = metaData[MPMediaItemPropertyArtist];
但当“音乐”应用在后台播放音乐时,它总是返回 nil。 我查了相关文件,上面写着
MPNowPlayingInfoCenter provides an interface for setting the current now
playing information for the application.
The default center holds now playing info about the current application
似乎无法通过MPNowPlayingInfoCenter 获取其他应用的nowPlayingInfo。那么还有其他方法可以让其他应用的音乐元数据显示在遥控器/锁定屏幕中吗?谢谢!
【问题讨论】:
-
为什么要获取其他应用的数据?
-
@Desmond 因为我想根据用户的兴趣向他/她推荐一些信息。音乐是一个很好的提示。
-
嗨,我曾尝试获取 nowplayinginfo,但无济于事。我不确定你是否能得到这些信息,因为所有应用程序都是沙盒的。
标签: ios avfoundation mpnowplayinginfocenter