Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios AVAssetExportSession进程在ipad上卡住了,但在模拟器上没有_Ios_Avfoundation_Avassetexportsession - Fatal编程技术网

Ios AVAssetExportSession进程在ipad上卡住了,但在模拟器上没有

Ios AVAssetExportSession进程在ipad上卡住了,但在模拟器上没有,ios,avfoundation,avassetexportsession,Ios,Avfoundation,Avassetexportsession,这段代码在模拟器上运行良好。然而,当我尝试在iPad上运行导出时,它总是挂起在进度值0.14583-ish。有人能帮我找出原因吗?这件事已经困扰了好一阵子了 这是我的密码: NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:composition]; if ([compatiblePresets containsObject:AVAssetExportPresetLowQuali

这段代码在模拟器上运行良好。然而,当我尝试在iPad上运行导出时,它总是挂起在进度值0.14583-ish。有人能帮我找出原因吗?这件事已经困扰了好一阵子了

这是我的密码:

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];

}
这个while循环阻塞了主线程。NSLog可能无法正常启动。不用while循环就试试吧?

这就是他为什么要睡觉(1)。我更喜欢[NSThread sleepForTimeInterval:1.0];
while(exportSession.progress != 1.0){
    NSLog(@"loading... : %f",exportSession.progress);
    sleep(1);
}