带有铃声软件的 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;}
}
}];
}
Best Answer-推荐答案 strong>
这样做是为了设置时间范围
[songAsset insertTimeRange:CMTimeRangeMake(kCMTimeZero, songAsset.duration)
ofTrack:[[songAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
atTime:kCMTimeZero
error:nil];
关于ios - AVAssetExportSession 不适用于 ios 7,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/19225914/
|