带有铃声软件的ios 7 不工作。ios 5 和 ios 6 工作正常。当我使用 ios 7 运行它时,铃声的持续时间与创建源文件的时间相同。需要40秒。但它似乎是 300-400 秒。
- (void)Convert{
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:self.audioplayer.url options:nil];
AVAssetExportSession *exporter = [[AVAssetExportSession alloc]
initWithAsset: songAsset
presetName: AVAssetExportPresetAppleM4A];
//exporter.outputFileType = @"com.apple.m4a-audio";
exporter.outputFileType = AVFileTypeAppleM4A;
CMTime start = CMTimeMakeWithSeconds(self.audioplayer.currentTime, 1);
CMTime duration = CMTimeMakeWithSeconds(40, 1);
CMTimeRange range = CMTimeRangeMake(start, duration);
exporter.timeRange = range;
NSString *exportFile = [[self kDoc_dosya:self.name] stringByAppendingPathExtension:@"m4r"];
if ([[NSFileManager defaultManager] fileExistsAtPath:exportFile])
[[NSFileManager defaultManager] removeItemAtPath:exportFile error:nil];
NSURL *exportURL = [NSURL fileURLWithPath:exportFile];
exporter.outputURL = exportURL;
[exporter exportAsynchronouslyWithCompletionHandler:^{
int exportStatus = exporter.status;
switch (exportStatus) {
case AVAssetExportSessionStatusFailed: {
NSError *exportError = exporter.error;
NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError);
break;
}
case AVAssetExportSessionStatusCompleted: {
NSLog (@"AVAssetExportSessionStatusCompleted--");
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;}
}
}];
}