我正在制作一个视频应用程序,在其中使用 AVAssetExportSession 创建一个新视频。在创建视频时,我想让用户能够取消视频创建。我遇到的问题是我不知道如何向 AVAssetExportSession 发送取消请求,因为我假设它在主线程上运行。一旦开始,我不知道如何发送停止请求?
我试过这个,但它不起作用
- (IBAction) startBtn
{
....
// Export
exportSession = [[AVAssetExportSession alloc] initWithAsset:[composition copy] presetName:AVAssetExportPresetHighestQuality];
[exportSession setOutputFileType:@"com.apple.quicktime-movie"];
exportSession.outputURL = outputMovieURL;
exportSession.videoComposition = mainComposition;
//NSLog(@"Went Here 7 ...");
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status])
{
case AVAssetExportSessionStatusCancelled:
NSLog(@"Canceled ...");
break;
case AVAssetExportSessionStatusCompleted:
{
NSLog(@"Complete ... %@",outputURL); // moview url
break;
}
case AVAssetExportSessionStatusFailed:
{
NSLog(@"Faild=%@ ...",exportSession.error);
break;
}
case AVAssetExportSessionStatusExporting:
NSLog(@"Exporting.....");
break;
}
}];
}
- (IBAction) cancelBtn
{
exportSession = nil;
}