Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS设备的锁屏上添加自定义相册艺术_Ios_Iphone_Mpmediaitem - Fatal编程技术网

在iOS设备的锁屏上添加自定义相册艺术

在iOS设备的锁屏上添加自定义相册艺术,ios,iphone,mpmediaitem,Ios,Iphone,Mpmediaitem,我正在构建一个iOS应用程序,可以播放shoutcast音频 我希望在设备锁屏上显示自定义图像(无论是哪首歌,我都希望显示相同的图像) 下面的代码会在锁屏上显示当前标题,但不会像下面的图片那样显示相册艺术 首先可能吗(我认为,Mixcloud实现了这一点)?如果是,这有什么问题?来源于此 Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter"); if (playingInfoCenter) { NSMu

我正在构建一个iOS应用程序,可以播放shoutcast音频

我希望在设备锁屏上显示自定义图像(无论是哪首歌,我都希望显示相同的图像)

下面的代码会在锁屏上显示当前标题,但不会像下面的图片那样显示相册艺术

首先可能吗(我认为,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];
}

这是我在应用程序中使用的代码。在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;

请告诉我是否适合您。

您的头衔和艺术家是否被正确更改/设置?是的。所有这些信息都已正确更新。您是否找到了解决方案?它过去在iOS 6上正常工作,但在iOS 7上坏了。。。我正在使用一个类似的代码,我也经历过这种情况issue@cujo30227:不幸的是,一年后,这个问题有什么解决办法吗?所有其他属性都很好,只有艺术品没有显示。是的,我设置的
MPMediaItemArtwork
可以从
nowPlayingInfo
字典中检索,并且可以通过FB-凿子
visualize(UIImage*)[0x7ffd7a4a8d20图像大小:CGSizeMake(128128)]
还有人知道锁屏艺术品显示所需的图像大小吗?除相册艺术品外,所有其他属性的作品都符合预期。我收回这一点。在iOS 8中对我来说很好