ios app退到播放器退到后台,MPNowPlayingIn
作者:
天上飞的狒狒 | 来源:发表于
2022-04-28 15:56 被阅读0次 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
//设置歌曲题目
NSString*titleStr = self.vod.title;
if (titleStr != nil && titleStr.length != 0) {
[dict setObject:titleStr forKey:MPMediaItemPropertyTitle];
}
//设置歌手名
[dict setObject:@"" forKey:MPMediaItemPropertyArtist];
//设置专辑名
[dict setObject:@"" forKey:MPMediaItemPropertyAlbumTitle];
//设置显示的图片
UIImage *newImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.vod.imageUrl]]];
#####//其中设置图片这一块有改动
##### //老的代码
// [dict setObject:[[MPMediaItemArtwork alloc] initWithImage:newImage] forKey:MPMediaItemPropertyArtwork];
#####//新的代码
#####//CGSizeMake(100, 200) 大小自定义
[dict setObject:[[MPMediaItemArtwork alloc] initWithBoundsSize:CGSizeMake(100, 200) requestHandler:^UIImage * _Nonnull(CGSize size) {
return newImage;
}] forKey:MPMediaItemPropertyArtwork];
//更新字典
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:dict];
本文标题:ios app退到播放器退到后台,MPNowPlayingIn
本文链接:https://www.haomeiwen.com/subject/toddyrtx.html
网友评论