开发环境:Xcode Version 7.3 (7D175)
模拟器版本:9.3
由于AVURLAsset相关资料较少,所以暂时只能先做其用法的分享,代码如下
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"PriceTag" ofType:@"mp3"]];
AVURLAsset *avURLAsset = [[AVURLAsset alloc] initWithURL:url options:nil];
for (AVMetadataItem *metadata in [avURLAsset metadata]){
NSLog(@"metadata.commonKey = %@", metadata.commonKey);
NSLog(@"metadata.key = %@", metadata.key);
NSLog(@"metadata.stringValue = %@", metadata.stringValue);
NSLog(@"metadata.dataValue = %@\n\n", metadata.dataValue);
//示例:获取图片
if([(NSString *)[metadata commonKey] isEqualToString:@"artwork"]){
UIImage *coverImage = [UIImage imageWithData:metadata.dataValue];//提取图片
self.imageV.image = coverImage;
}
}