Video avatar fixes

This commit is contained in:
Ilya Laktyushin 2020-07-02 15:03:41 +03:00
parent 7797740b25
commit 5c1263ff12
2 changed files with 38 additions and 16 deletions

View File

@ -352,6 +352,7 @@
if ([self presentedForAvatarCreation] && _item.isVideo) { if ([self presentedForAvatarCreation] && _item.isVideo) {
_scrubberView = [[TGMediaPickerGalleryVideoScrubber alloc] initWithFrame:CGRectMake(0.0f, 0.0, _portraitToolbarView.frame.size.width, 68.0f)]; _scrubberView = [[TGMediaPickerGalleryVideoScrubber alloc] initWithFrame:CGRectMake(0.0f, 0.0, _portraitToolbarView.frame.size.width, 68.0f)];
_scrubberView.layer.allowsGroupOpacity = true;
_scrubberView.hasDotPicker = true; _scrubberView.hasDotPicker = true;
_scrubberView.dataSource = self; _scrubberView.dataSource = self;
_scrubberView.delegate = self; _scrubberView.delegate = self;
@ -837,6 +838,16 @@
[_portraitToolbarView setDoneButtonEnabled:enabled animated:animated]; [_portraitToolbarView setDoneButtonEnabled:enabled animated:animated];
[_landscapeToolbarView setDoneButtonEnabled:enabled animated:animated]; [_landscapeToolbarView setDoneButtonEnabled:enabled animated:animated];
if (animated) {
[UIView animateWithDuration:0.2 animations:^{
_scrubberView.alpha = enabled ? 1.0 : 0.2;
}];
} else {
_scrubberView.alpha = enabled ? 1.0 : 0.2;
}
_scrubberView.userInteractionEnabled = enabled;
} }
- (void)updateStatusBarAppearanceForDismiss - (void)updateStatusBarAppearanceForDismiss
@ -2678,28 +2689,35 @@
id<TGMediaEditAdjustments> adjustments = [_photoEditor exportAdjustments]; id<TGMediaEditAdjustments> adjustments = [_photoEditor exportAdjustments];
__weak TGPhotoEditorController *weakSelf = self;
SSignal *thumbnailsSignal = nil; SSignal *thumbnailsSignal = nil;
if (_cachedThumbnails != nil) { if (_cachedThumbnails != nil) {
thumbnailsSignal = [SSignal single:_cachedThumbnails]; thumbnailsSignal = [SSignal single:_cachedThumbnails];
} else if ([self.item isKindOfClass:[TGMediaAsset class]]) { } else if ([self.item isKindOfClass:[TGMediaAsset class]]) {
thumbnailsSignal = [[SSignal single:[self _placeholderThumbnails:timestamps]] then:[TGMediaAssetImageSignals videoThumbnailsForAsset:(TGMediaAsset *)self.item size:size timestamps:timestamps]]; thumbnailsSignal = [[SSignal single:[self _placeholderThumbnails:timestamps]] then:[[TGMediaAssetImageSignals videoThumbnailsForAsset:(TGMediaAsset *)self.item size:size timestamps:timestamps] onNext:^(NSArray *images) {
} else if ([self.item isKindOfClass:[TGCameraCapturedVideo class]]) {
thumbnailsSignal = [[((TGCameraCapturedVideo *)self.item).avAsset takeLast] mapToSignal:^SSignal *(AVAsset *avAsset) {
return [[SSignal single:[self _placeholderThumbnails:timestamps]] then:[TGMediaAssetImageSignals videoThumbnailsForAVAsset:avAsset size:size timestamps:timestamps]];
}];
}
_requestingThumbnails = true;
__weak TGPhotoEditorController *weakSelf = self;
[_thumbnailsDisposable setDisposable:[[[[thumbnailsSignal onNext:^(NSArray *images) {
__strong TGPhotoEditorController *strongSelf = weakSelf; __strong TGPhotoEditorController *strongSelf = weakSelf;
if (strongSelf == nil) if (strongSelf == nil)
return; return;
if (strongSelf->_cachedThumbnails == nil) if (strongSelf->_cachedThumbnails == nil)
strongSelf->_cachedThumbnails = images; strongSelf->_cachedThumbnails = images;
}] map:^NSArray *(NSArray *images) { }]];
} else if ([self.item isKindOfClass:[TGCameraCapturedVideo class]]) {
thumbnailsSignal = [[((TGCameraCapturedVideo *)self.item).avAsset takeLast] mapToSignal:^SSignal *(AVAsset *avAsset) {
return [[SSignal single:[self _placeholderThumbnails:timestamps]] then:[[TGMediaAssetImageSignals videoThumbnailsForAVAsset:avAsset size:size timestamps:timestamps] onNext:^(NSArray *images) {
__strong TGPhotoEditorController *strongSelf = weakSelf;
if (strongSelf == nil)
return;
if (strongSelf->_cachedThumbnails == nil)
strongSelf->_cachedThumbnails = images;
}]];
}];
}
_requestingThumbnails = true;
[_thumbnailsDisposable setDisposable:[[[thumbnailsSignal map:^NSArray *(NSArray *images) {
if (adjustments.toolsApplied) { if (adjustments.toolsApplied) {
NSMutableArray *editedImages = [[NSMutableArray alloc] init]; NSMutableArray *editedImages = [[NSMutableArray alloc] init];
PGPhotoEditor *editor = [[PGPhotoEditor alloc] initWithOriginalSize:adjustments.originalSize adjustments:adjustments forVideo:false enableStickers:true]; PGPhotoEditor *editor = [[PGPhotoEditor alloc] initWithOriginalSize:adjustments.originalSize adjustments:adjustments forVideo:false enableStickers:true];

View File

@ -506,15 +506,19 @@ UIImageOrientation TGVideoOrientationForAsset(AVAsset *asset, bool *mirrored)
*mirrored = (scale.width < 0); *mirrored = (scale.width < 0);
} }
if (fabs(videoRotation - M_PI) < FLT_EPSILON) if (fabs(videoRotation - M_PI) < FLT_EPSILON) {
return UIImageOrientationLeft; return UIImageOrientationLeft;
else if (fabs(videoRotation - M_PI_2) < FLT_EPSILON) } else if (fabs(videoRotation - M_PI_2) < FLT_EPSILON) {
if (t.c == 1 && mirrored != NULL) {
*mirrored = true;
}
return UIImageOrientationUp; return UIImageOrientationUp;
else if (fabs(videoRotation + M_PI_2) < FLT_EPSILON) } else if (fabs(videoRotation + M_PI_2) < FLT_EPSILON) {
return UIImageOrientationDown; return UIImageOrientationDown;
else } else {
return UIImageOrientationRight; return UIImageOrientationRight;
} }
}
UIImageOrientation TGVideoFinalOrientationForOrientation(UIImageOrientation videoOrientation, UIImageOrientation cropOrientation) UIImageOrientation TGVideoFinalOrientationForOrientation(UIImageOrientation videoOrientation, UIImageOrientation cropOrientation)
{ {