得到mp3中的图片

AVURLAsset *mp3Asset = [AVURLAsset URLAssetWithURL:fileURL options:nil];

for (NSString *format in [mp3Asset availableMetadataFormats]) {

        NSLog(@"-------format:%@",format);

        for (AVMetadataItem *metadataItem in [mp3Asset metadataForFormat:format]) {

            NSLog(@"commonKey:%@",metadataItem.commonKey);

            if ([metadataItem.commonKey isEqualToString:@"artwork"]) {

                //取出封面artwork,从data转成image显示

                musicCell.imageView.image = [UIImage imageWithData:[(NSDictionary*)metadataItem.valueobjectForKey:@"data"]];

            }

        }

    }

    //取得播放路径

    AVURLAsset *mp3Asset = [musicArray objectAtIndex:indexPath.row];

    //mp3文件路径得url

    NSURL *mp3URL = mp3Asset.URL;

转载于:https://www.cnblogs.com/ThankForYou/archive/2012/09/08/2677110.html

你可能感兴趣的:(得到mp3中的图片)