Damonvvong / DevNotes

个人开发笔记。
MIT License
426 stars 80 forks source link

你的demo如果录制视频点击几次屏幕后会崩溃,reason: '*** -[AVAssetWriter finishWritingWithCompletionHandler:] Cannot call method when status is 2' #5

Open xinyu1105 opened 6 years ago

xinyu1105 commented 6 years ago

self.isWriting = NO;

dispatch_async(self.dispatchQueue, ^{

[self.assetWriter finishWritingWithCompletionHandler:^{

    if (self.assetWriter.status == AVAssetWriterStatusCompleted) {

        dispatch_async(dispatch_get_main_queue(), ^{
            if ([self.delegate respondsToSelector:@selector(videoWriter:didOutputVideoAtPath:)]) {
                [self.delegate videoWriter:self didOutputVideoAtPath:self.assetWriter.outputURL];
            }
        });

    } else {

        *error = self.assetWriter.error;

    }
    self.assetWriter = nil;
}];

}); }

这个怎么解决呢?麻烦回复下,谢谢!!