Dav*_*vid 5 iphone mpmediaitem ios
我正在构建一个流播shoutcast音频的iOS应用程序.
我想在设备锁屏上显示自定义图像(无论是哪首歌,我都希望显示相同的图像).
下面的代码向我展示了锁屏上的当前标题,但没有显示专辑艺术,就像下面的图像一样.
有可能首先(我认为,Mixcloud实现了它)?如果是的话,这有什么问题?来源于此.
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
UIImage * albumImage = [UIImage imageNamed: @"icon_HD.png"];
MPMediaItemArtwork * albumArt = [[MPMediaItemArtwork alloc] initWithImage:albumImage];
[songInfo setObject:titre.text forKey:MPMediaItemPropertyTitle];
[songInfo setObject:artiste.text forKey:MPMediaItemPropertyArtist];
[songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
}
Run Code Online (Sandbox Code Playgroud)
小智 6
这是我在我的应用程序上使用的代码.适用于iOS7
UIImage *image = [UIImage imageNamed:@"myImage.png"];
MPMediaItemArtwork *albumArtwork = [[MPMediaItemArtwork alloc] initWithImage:image];
NSDictionary *info = @{ MPMediaItemPropertyTitle: @"Song Name",
MPMediaItemPropertyArtist: @"Artist Name",
MPMediaItemPropertyAlbumTitle: @"Album Name",
MPMediaItemPropertyPlaybackDuration: 1.0,
MPNowPlayingInfoPropertyElapsedPlaybackTime: 1.0,
MPMediaItemPropertyArtwork: albumArtwork };
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = info;
Run Code Online (Sandbox Code Playgroud)
让我知道是否适合你.
| 归档时间: |
|
| 查看次数: |
1526 次 |
| 最近记录: |