2
이 코드 조각은 시뮬레이터에서 정상적으로 작동합니다. 그러나 내 iPad에서 내보내기를 실행하려고하면 진행률 값 0.14583-ish가 항상 중단됩니다. 왜 누군가가 나를 알아낼 수 있습니까? 꽤 잠시 동안 이것에 붙어 있었다.AVAssetExportSession 진행률이 ipad에서는 멈추지 만 시뮬레이터에서는 멈추지 않습니다
NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:composition];
if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality]) {
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
initWithAsset:composition presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = [NSURL fileURLWithPath:[[ShowDAO getUserDocumentDir] stringByAppendingString:exportFilename]];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTime start = CMTimeMakeWithSeconds(0, 1);
CMTime duration = CMTimeMakeWithSeconds(1000, 1);
CMTimeRange range = CMTimeRangeMake(start, duration);
exportSession.timeRange = range;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status]) {
case AVAssetExportSessionStatusCompleted:
NSLog(@"Export Completed");
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]);
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export cancelled");
break;
default:
break;
}
}];
while(exportSession.progress != 1.0){
NSLog(@"loading... : %f",exportSession.progress);
sleep(1);
}
[exportSession release];
}
그래서 그는 수면을 취하고 있습니다 (1). 나는 [NSThread sleepForTimeInterval : 1.0]을 선호한다. –