Ich hatte den folgenden Code ausprobiert.iOS 6 Problem MPMediaItem zu NSData konvertieren
-(void)mediaItemToData : (MPMediaItem *) curItem
{
NSURL *url = [curItem valueForProperty: MPMediaItemPropertyAssetURL];
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: url options:nil];
AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset
presetName:AVAssetExportPresetPassthrough];
exporter.outputFileType = @"public.mpeg-4";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * myDocumentsDirectory = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSString *exportFile = [myDocumentsDirectory stringByAppendingPathComponent:
@"exported.mp4"];
NSURL *exportURL = [NSURL fileURLWithPath:exportFile];
exporter.outputURL = exportURL;
// do the export
// (completion handler block omitted)
[exporter exportAsynchronouslyWithCompletionHandler:
^{
NSData *data = [NSData dataWithContentsOfFile: [myDocumentsDirectory
stringByAppendingPathComponent: @"exported.mp4"]];
DLog(@"Data %@",data);
}];
}
dieser Code funktioniert in iOS 5 in Ordnung, aber arbeiten jetzt in iOS 6.
Änderungen für iOS6 in AVAssetExportPresetPassthrough
. ???
haben einen Blick auf diesen Link nicht sicher hilfreich sein könnte http://www.subforther.com/blog/2010/07/19/from-iphone-media-library-to-pcm-samples-in-dozens-of-confounding-potentially-lossy-steps/ – Leena
@Leena Danke y Unser Link ist hilfreich, um dies zu beheben. – Hitarth