sam*_*ize 9 core-audio ios mpnowplayinginfocenter
播放音乐时,音乐标题会显示在锁定屏幕中的时间下方.
我还看到了TuneIn无线电是如何通过显示当前正在播放的广播电台的名称来实现的.
你是怎样做的?
rck*_*nes 27
阅读文档: MPNowPlayingInfoCenter
这是一个可以在iOS 5上运行的示例代码,它不会在旧版本的iOS上崩溃.
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
NSDictionary *songInfo = [NSDictionary dictionaryWithObjectsAndKeys:
@"Some artist", MPMediaItemPropertyArtist,
@"Some title", MPMediaItemPropertyTitle,
@"Some Album", MPMediaItemPropertyAlbumTitle,
nil];
center.nowPlayingInfo = songInfo;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5609 次 |
| 最近记录: |