iPhone:如何从[_assetExport exportAsynchronouslyWithCompletionHandler:^(void){}调用其他方法

Dev*_*ang 2 iphone cocoa-touch objective-c ios

我使用下面的代码合并.mp4.caf.mov.(注意:我知道如何播放视频,所以不要给出代码)

 AVAssetExportSession* _assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition 
                                                                      presetName:AVAssetExportPresetPassthrough];  //AVAssetExportPresetPassthrough 

NSString* videoName = @"export.mov";

NSString *exportPath = [document stringByAppendingPathComponent:videoName];
NSURL    *exportUrl = [NSURL fileURLWithPath:exportPath];
NSLog(@"Export : %@",exportUrl);

if ([[NSFileManager defaultManager] fileExistsAtPath:exportPath]) 
{
    [[NSFileManager defaultManager] removeItemAtPath:exportPath error:nil];
}

_assetExport.outputFileType = AVFileTypeQuickTimeMovie;//@"com.apple.quicktime-movie";
NSLog(@"file type %@",_assetExport.outputFileType);
_assetExport.outputURL = exportUrl;
_assetExport.shouldOptimizeForNetworkUse = YES;
Run Code Online (Sandbox Code Playgroud)
[_assetExport exportAsynchronouslyWithCompletionHandler:
 ^(void ) {  
     switch (_assetExport.status) 
     {
         case AVAssetExportSessionStatusCompleted:
             //   export complete 

             NSLog(@"Export Complete");
       ------>>> // From Here I want play movie using MPMoviePlayerController.<<<--------- 


             break;
         case AVAssetExportSessionStatusFailed:
             NSLog(@"Export Failed");
             NSLog(@"ExportSessionError: %@", [_assetExport.error localizedDescription]);

             //                export error (see exportSession.error)  
             break;
         case AVAssetExportSessionStatusCancelled:
             NSLog(@"Export Failed");
             NSLog(@"ExportSessionError: %@", [_assetExport.error localizedDescription]);

             //                export cancelled  
             break;

     }


 }       

 ];
Run Code Online (Sandbox Code Playgroud)

所以对于播放视频,我打电话给其他方法,[self playVideo]但它没有播放.

我试图使用这种方法b'coz [_assetExport exportAsynchronouslyWithCompletionHandler: ^(void ) { }将使用其他线程导出视频.

如果我尝试[self playVideo]在上面的代码后调用.它不会获得视频b'coz视频仍然在上述方法下创建.

我也尝试通知AVAssetExportSessionStatusCompleted但不播放视频.

所以我的问题是如何从该方法播放视频?或者如何将控制切换到主线程以便我可以成功播放视频?

mal*_*hal 6

像这样:

[self performSelectorOnMainThread:@selector(playVideo) withObject:nil waitUntilDone:NO];
Run Code Online (Sandbox Code Playgroud)