I am reading a video file and processing it. The code for it is based on the code in this question.
AVURLAsset * asset = [AVURLAsset URLAssetWithURL:url options:nil];
[asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:@"tracks"] completionHandler:
^{
dispatch_async(dispatch_get_main_queue(),
^{
AVAssetTrack * videoTrack = nil;
NSArray * tracks = [asset tracksWithMediaType:AVMediaTypeVideo];
if ([tracks count] == 1)
{
//some code here
[movieReader startReading];
while ([movieReader status] == AVAssetReaderStatusReading)
{
// reading the video code here
}
}
});
});
I need to update the UI as I process each frame indicating the progress of processing frames. I insert a button on the UI inside the while loop, however, the UI gets updated only when the entire video processing is complete. Infact, any UI update performed in the completion handler block takes place only after the entire processing. Any suggestions on how to do it ?