I have some NSData
variables which contain .m4a
/ .mp4
file formats. I've tried looking at ways to convert the NSData
into file format, with no luck. I need to convert it into a file, change some of it's metadata, and convert it back to NSData
. Here's some code:
// This JSON basically gets the url of a .m4a
NSArray *preview = [JSON valueForKeyPath:@"results.previewUrl"];
_previewData = [NSMutableData dataWithContentsOfURL:[NSURL URLWithString:[preview objectAtIndex:0]]];
[_previewData writeToFile:path atomically:YES];
ANMovie* file = [[ANMovie alloc] initWithFile:_previewData]; // or .mp4
NSData* jpegCover = UIImageJPEGRepresentation(artworkImage, 1.0);
ANMetadata* metadata = [[ANMetadata alloc] init];
metadata.albumCover = [[ANMetadataImage alloc] initWithImageData:jpegCover type:ANMetadataImageTypeJPG];
[file setMovieMetadata:metadata];
[file close];
I'm guessing [[ANMovie alloc] initWithFile:]
expects a file, and you've passed it, I'm also assuming here, an NSData*
.
Try:
ANMovie* file = [[ANMovie alloc] initWithFile:path];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.