我正在使用下面的代码从库中获取音频以进行修剪
在这里我的问题是我能够获得音频但是需要很长时间才能获得音频
AAVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:appDelegate.librarySongURL options:nil];
NSLog (@"Core Audio %@ directly open library URL %@",
coreAudioCanOpenURL (appDelegate.librarySongURL) ? @"can" : @"cannot",
appDelegate.librarySongURL);
NSLog (@"compatible presets for songAsset: %@",
[AVAssetExportSession exportPresetsCompatibleWithAsset:songAsset]);
AVAssetExportSession *exporter = [[AVAssetExportSession alloc]
initWithAsset: songAsset
presetName: AVAssetExportPresetAppleM4A];
NSLog (@"created exporter. supportedFileTypes: %@", exporter.supportedFileTypes);
[self handlePlayPauseDefault:0];
exporter.outputFileType = @"com.apple.m4a-audio";
NSString *exportFile = [myDocumentsDirectory() stringByAppendingPathComponent: @"exported.m4a"];
myDeleteFile(exportFile);
appDelegate.libraryUrl = [NSURL fileURLWithPath:exportFile];
exporter.outputURL = appDelegate.libraryUrl;
[exporter exportAsynchronouslyWithCompletionHandler:^{
int exportStatus = exporter.status;
switch (exportStatus) {
case AVAssetExportSessionStatusFailed: {
NSError *exportError = exporter.error;
NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError);
break;
}
case AVAssetExportSessionStatusCompleted: {
NSLog (@"AVAssetExportSessionStatusCompleted");
self.navigationController.navigationBar.userInteractionEnabled = YES;
break;
}
case AVAssetExportSessionStatusUnknown: { NSLog (@"AVAssetExportSessionStatusUnknown"); break;}
case AVAssetExportSessionStatusExporting: { NSLog (@"AVAssetExportSessionStatusExporting"); break;}
case AVAssetExportSessionStatusCancelled: { NSLog (@"AVAssetExportSessionStatusCancelled"); break;}
case AVAssetExportSessionStatusWaiting: { NSLog (@"AVAssetExportSessionStatusWaiting"); break;}
default: { NSLog (@"didn't get export status"); break;}
}
}];
谁能帮我 ?