Ope*_*ead 1 iphone background-music
我正在开发一个收音机应用程序,支持在后台播放音乐.但我陷入了如何设置音乐标题以消除控制.
我的应用和"音乐"之间的区别如下:

我应该怎么做让我的应用程序显示像"音乐"这样的音乐的标题呢?
谢谢!
这是示例代码:
#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];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
409 次 |
| 最近记录: |