我正在开发一个广播应用程序,它支持在后台播放音乐。但我陷入了如何设置音乐标题以取消控制的困境。
The difference between my app and "Music" is as following:
我应该怎么做才能让我的应用程序显示像“音乐”这样的音乐标题?
Thanks!
这是示例代码:
#import <MediaPlayer/MPNowPlayingInfoCenter.h>
#import <MediaPlayer/MPMediaItem.h>
MPMediaItemArtwork *albumArt;
- (void)changeTrackTitles
{
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter)
{
albumArt = [[MPMediaItemArtwork alloc] initWithImage: [UIImage imageNamed:@"HexagonArtwork"]];
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
[songInfo setObject:@"SongName" forKey:MPMediaItemPropertyTitle];
[songInfo setObject:@"AlbumName" forKey:MPMediaItemPropertyAlbumTitle];
[songInfo setObject:@"ArtistName" forKey:MPMediaItemPropertyArtist];
[songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)