Skip to content

Commit

Permalink
-调整线程的调用引起视频编辑问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lincf0912 committed Jul 31, 2017
1 parent 8900c97 commit da4cb47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,18 @@ - (void)finishButtonClick
__block LFVideoEdit *videoEdit = nil;
NSDictionary *data = [_EditingView photoEditData];
if (data) {
[_EditingView exportAsynchronouslyWithTrimVideo:^(NSURL *trimURL) {

videoEdit = [[LFVideoEdit alloc] initWithEditURL:weakSelf.editURL editFinalURL:trimURL data:data];
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{
[_EditingView exportAsynchronouslyWithTrimVideo:^(NSURL *trimURL, NSError *error) {
videoEdit = [[LFVideoEdit alloc] initWithEditURL:weakSelf.editURL editFinalURL:trimURL data:data];
if (error) {
[[[UIAlertView alloc] initWithTitle:nil message:error.localizedDescription delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil] show];
}
if ([weakSelf.delegate respondsToSelector:@selector(lf_VideoEditingController:didFinishPhotoEdit:)]) {
[weakSelf.delegate lf_VideoEditingController:weakSelf didFinishPhotoEdit:videoEdit];
}
[weakSelf hideProgressHUD];
});
}];
}];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
if ([weakSelf.delegate respondsToSelector:@selector(lf_VideoEditingController:didFinishPhotoEdit:)]) {
Expand Down Expand Up @@ -507,10 +509,14 @@ - (void)changeStickerMenu:(BOOL)isChanged

- (void)showTextBarController:(LFText *)text
{
LFTextBar *textBar = [[LFTextBar alloc] initWithFrame:CGRectMake(0, self.view.height, self.view.width, self.view.height)];
LFTextBar *textBar = [[LFTextBar alloc] initWithFrame:CGRectMake(0, self.view.height, self.view.width, self.view.height) layout:^(LFTextBar *textBar) {
textBar.oKButtonTitleColorNormal = self.oKButtonTitleColorNormal;
textBar.cancelButtonTitleColorNormal = self.cancelButtonTitleColorNormal;
textBar.oKButtonTitle = self.oKButtonTitle;
textBar.cancelButtonTitle = self.cancelButtonTitle;
}];
textBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
textBar.showText = text;
textBar.oKButtonTitleColorNormal = self.oKButtonTitleColorNormal;
textBar.delegate = self;

[self.view addSubview:textBar];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
- (void)setVideoAsset:(AVAsset *)asset placeholderImage:(UIImage *)image;

/** 剪辑视频 */
- (void)exportAsynchronouslyWithTrimVideo:(void (^)(NSURL *trimURL))complete;
- (void)exportAsynchronouslyWithTrimVideo:(void (^)(NSURL *trimURL, NSError *error))complete;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
}

/** 剪辑视频 */
- (void)exportAsynchronouslyWithTrimVideo:(void (^)(NSURL *trimURL))complete
- (void)exportAsynchronouslyWithTrimVideo:(void (^)(NSURL *trimURL, NSError *error))complete
{
NSError *error = nil;
NSFileManager *fm = [NSFileManager new];
Expand Down Expand Up @@ -218,7 +218,7 @@ - (void)exportAsynchronouslyWithTrimVideo:(void (^)(NSURL *trimURL))complete
self.exportSession.overlayView = self.clippingView.overlayView;

[self.exportSession exportAsynchronouslyWithCompletionHandler:^(NSError *error) {
if (complete) complete((error ? nil : trimURL));
if (complete) complete(trimURL, error);
}];
}

Expand Down

0 comments on commit da4cb47

Please sign in to comment.