我正在看苹果的文档,我似乎找不到一种方法来了解MPMediaItem是否是“最喜欢的”曲目。请看下面的屏幕截图,粉红色的心。
如何才能获得此属性?我知道由于它是一个新特性,它的可用性将被限制在iOS 8.4或更高版本。
下面是我用来通过音乐选择器从MPMediaItems获取其他属性的一些代码:
- (void) processMediaItems:(MPMediaItemCollection *)mediaItemCollection
{
//iterate through selected songs
if (mediaItemCollection) {
NSArray *allSelectedSongs = [mediaItemCollection items];
for(MPMediaItem *song in allSelectedSongs)
{
NSURL *songURL = [song valueForProperty:MPMediaItemPropertyAssetURL];
NSNumber *ident = [song valueForProperty:MPMediaEntityPropertyPersistentID];
NSString *identString = [BukketHelper convertULLToNSString:ident];
NSNumber *isCloud = [song valueForProperty:MPMediaItemPropertyIsCloudItem];
}
//do other stuff here
}
有谁有主意吗?
发布于 2018-06-09 07:31:12
你必须使用Apple Music API来获取或设置用户对这样一首歌的喜欢/不喜欢:
GET https://api.music.apple.com/v1/me/ratings/songs/{id}
https://stackoverflow.com/questions/35443693
复制相似问题