ios - AVAssetExportSession 进度卡在 ipad 上但不在模拟器上
<p><p>这段代码在模拟器上运行良好。但是,当我尝试在我的 iPad 上运行导出时,它总是以 0.14583-ish 的进度值挂起。有人可以帮我弄清楚为什么吗?卡在这上面好久了。</p>
<p>这是我的代码:</p>
<pre><code>NSArray *compatiblePresets = ;
if () {
AVAssetExportSession *exportSession = [
initWithAsset:composition presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = 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 () {
case AVAssetExportSessionStatusCompleted:
NSLog(@"Export Completed");
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Export failed: %@", [ localizedDescription]);
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export cancelled");
break;
default:
break;
}
}];
while(exportSession.progress != 1.0){
NSLog(@"loading... : %f",exportSession.progress);
sleep(1);
}
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>while(exportSession.progress != 1.0){
NSLog(@"loading... : %f",exportSession.progress);
sleep(1);
}
</code></pre>
<p>这个while循环阻塞了主线程。 NSLog 可能无法正常触发。不使用 while 循环试试?</p></p>
<p style="font-size: 20px;">关于ios - AVAssetExportSession 进度卡在 ipad 上但不在模拟器上,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/7702977/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/7702977/
</a>
</p>
页:
[1]