目标C:获取MPMediaItem的“收藏夹"属性 [英] Objective C: Getting MPMediaItem 'Favorite' property
问题描述
我正在查看Apple的文档,但似乎找不到找到MPMediaItem是否为收藏夹"曲目的方法.见下面的截图,带有粉红色的心.
I was looking at Apple's documentation, and I cannot seem to find a way to get whether or not an MPMediaItem is a 'favorite' track or not. See screenshot below, with the pink heart.
如何获得此财产?我知道,由于它是一项新功能,因此它的可用性仅限于iOS 8.4或更高版本.
How can one get this property? I know since it's a new feature, it's availability would be limited to iOS 8.4 or later.
以下是我用来通过音乐选择器从MPMediaItems中获取其他属性的一些代码:
Here's some code I'm using to get other properties from MPMediaItems, via the music picker:
- (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
}
有人有想法吗?
推荐答案
您必须使用Apple Music API才能将用户的赞/不喜欢"或设置为像这样的歌曲:
You have to use Apple Music API to get or set users's Like/Dislike to a song like this:
GET https://api.music.apple.com/v1/me/ratings/songs/{id}
来自: Apple文档链接
这篇关于目标C:获取MPMediaItem的“收藏夹"属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!