From 51a95f3f6ff23403490f3371b58dffac7eff87d8 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 28 Jun 2020 16:49:35 +0300 Subject: [PATCH] Video avatar fixes --- .../Sources/TGPhotoEditorController.m | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index b977d315f8..9f7312c17d 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -486,33 +486,33 @@ progress = 1.0f; } } else if ([next isKindOfClass:[AVAsset class]]) { -// strongSelf->_playerItem = [AVPlayerItem playerItemWithAsset:(AVAsset *)next]; -// strongSelf->_player = [AVPlayer playerWithPlayerItem:strongSelf->_playerItem]; -// strongSelf->_player.actionAtItemEnd = AVPlayerActionAtItemEndNone; -// strongSelf->_player.muted = true; -// -// [photoEditor setPlayerItem:strongSelf->_playerItem forCropRect:photoEditor.cropRect cropRotation:0.0 cropOrientation:photoEditor.cropOrientation cropMirrored:photoEditor.cropMirrored]; -// -// TGDispatchOnMainThread(^ -// { -// if ([strongSelf->_currentTabController isKindOfClass:[TGPhotoAvatarCropController class]]) -// [(TGPhotoAvatarCropController *)strongSelf->_currentTabController setPlayer:strongSelf->_player]; -// -// [strongSelf->_previewView performTransitionInWithCompletion:^ -// { -// }]; -// -// if (strongSelf->_scheduledVideoPlayback) { -// strongSelf->_scheduledVideoPlayback = false; -// [strongSelf startVideoPlayback:true]; -// } -// }); + strongSelf->_playerItem = [AVPlayerItem playerItemWithAsset:(AVAsset *)next]; + strongSelf->_player = [AVPlayer playerWithPlayerItem:strongSelf->_playerItem]; + strongSelf->_player.actionAtItemEnd = AVPlayerActionAtItemEndNone; + strongSelf->_player.muted = true; + + [photoEditor setPlayerItem:strongSelf->_playerItem forCropRect:photoEditor.cropRect cropRotation:0.0 cropOrientation:photoEditor.cropOrientation cropMirrored:photoEditor.cropMirrored]; + + TGDispatchOnMainThread(^ + { + if ([strongSelf->_currentTabController isKindOfClass:[TGPhotoAvatarCropController class]]) + [(TGPhotoAvatarCropController *)strongSelf->_currentTabController setPlayer:strongSelf->_player]; + + [strongSelf->_previewView performTransitionInWithCompletion:^ + { + }]; + + if (strongSelf->_scheduledVideoPlayback) { + strongSelf->_scheduledVideoPlayback = false; + [strongSelf startVideoPlayback:true]; + } + }); progress = 1.0f; doneEnabled = true; } else if ([next isKindOfClass:[NSNumber class]]) { progress = [next floatValue]; progressVisible = true; -// doneEnabled = false; + doneEnabled = false; } TGDispatchOnMainThread(^{