从ID3标签/转换功能从Java到Objective-C获取专辑图片 [英] Get album artwork from ID3 tag/Convert function from Java to Objective-C
问题描述
我有以下问题要问:
如何使用iOS应用程序编译taglib?
How do you compile taglib with an iOS application?
我有点困惑,因为我将文件夹添加到我的项目中,尝试编译它,但它失败了1640错误。
I'm a bit confused as I added the folder into my project, tried to compile it, but instead it failed with 1640 errors.
我如何制作它成功编译 - 我问的原因是taglib允许从标签中提取专辑图片。
How do I make it successfully compile - the reason why I ask is taglib allows for the extraction of album artwork from a tag.
如果有人知道基于Objective-C的专辑图片提取类它会有所帮助 - 我不知道为什么Apple不会在Core Foundation中添加这样做的方法 - 因为有一些方法可以从ID3标签中提取一些数据。
If anyone knows an Objective-C based album artwork extraction class it would help - I don't know why Apple don't add a way of doing this in Core Foundation - because there are methods for extracting some of the data from an ID3 tag.
我不明白为什么没有一些 Objective-C的方式。
I can't see why there isn't some Objective-C way of doing it.
任何帮助表示感谢。
编辑:
经过几个小时的尝试,我发现了一个Java函数这里似乎做得很好,但我还没有得到关于如何转换的线索它是Objective-C(或者更不用说C ++),因为它的类型似乎与Objective-C / C ++中的类型完全不同。
如果有人知道转换它的方法,它会真的帮助,因为这似乎是我最后的选择,因为我已经尝试了很多其他选项。
After hours upon hours of trying to do this, I've found a Java function here that seems to do the job fine, but I haven't got a clue on how to convert it to Objective-C (or let alone C++ for that matter), as its types seem to be completely different from those that are in Objective-C/C++.
If anyone knows of a way to convert this it would really help, as this seems as my last option as I've tried so many others.
推荐答案
- (void)loadArtworksForFileAtPath:(NSString *)path completion:(void (^)(NSArray *))completion
{
NSURL *u = [NSURL fileURLWithPath:path];
AVURLAsset *a = [AVURLAsset URLAssetWithURL:u options:nil];
NSArray *k = [NSArray arrayWithObjects:@"commonMetadata", nil];
[a loadValuesAsynchronouslyForKeys:k completionHandler: ^{
NSArray *artworks = [AVMetadataItem metadataItemsFromArray:a.commonMetadata
withKey:AVMetadataCommonKeyArtwork keySpace:AVMetadataKeySpaceCommon];
NSMutableArray *artworkImages = [NSMutableArray array];
for (AVMetadataItem *i in artworks)
{
NSString *keySpace = i.keySpace;
UIImage *im = nil;
if ([keySpace isEqualToString:AVMetadataKeySpaceID3])
{
NSDictionary *d = [i.value copyWithZone:nil];
im = [UIImage imageWithData:[d objectForKey:@"data"]];
}
else if ([keySpace isEqualToString:AVMetadataKeySpaceiTunes])
im = [UIImage imageWithData:[i.value copyWithZone:nil]];
if (im)
[artworkImages addObject:im];
}
completion(artworkImages);
}];
}
这篇关于从ID3标签/转换功能从Java到Objective-C获取专辑图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!