From 58cc60eaa1fcfa4a489ab345ac84a4b6a146c6b9 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 11 Jul 2020 12:41:25 +0300 Subject: [PATCH] Video avatar fixes --- .../LegacyComponents/TGPhotoEditorTabController.h | 1 + .../Sources/TGPhotoAvatarPreviewController.m | 10 +++++++++- .../LegacyComponents/Sources/TGPhotoEditorController.m | 7 ++++++- .../Sources/PeerInfo/PeerInfoHeaderNode.swift | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorTabController.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorTabController.h index 7ee9d2b520..ee21c29ebe 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorTabController.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorTabController.h @@ -29,6 +29,7 @@ @property (nonatomic, copy) void (^tabsChanged)(void); +@property (nonatomic, copy) bool (^isVideoPlaying)(); @property (nonatomic, copy) void (^controlVideoPlayback)(bool); @property (nonatomic, copy) void (^controlVideoSeek)(NSTimeInterval); @property (nonatomic, copy) void (^controlVideoEndTime)(NSTimeInterval); diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m index 138c163556..83f5edd1b5 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m @@ -43,6 +43,8 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel UIView *_landscapeToolControlView; UILabel *_coverLabel; + bool _wasPlayingBeforeCropping; + bool _scheduledTransitionIn; } @@ -80,6 +82,10 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel if (strongSelf == nil) return; + if (strongSelf.isVideoPlaying != nil) { + strongSelf->_wasPlayingBeforeCropping = strongSelf.isVideoPlaying(); + } + strongSelf.controlVideoPlayback(false); }; void(^interactionEnded)(void) = ^ @@ -91,7 +97,9 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel if ([strongSelf shouldAutorotate]) [TGViewController attemptAutorotation]; - strongSelf.controlVideoPlayback(true); + if (strongSelf->_wasPlayingBeforeCropping) { + strongSelf.controlVideoPlayback(true); + } }; PGPhotoEditor *photoEditor = self.photoEditor; diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index 24ed610fcc..e4b65d1d0c 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -1274,6 +1274,12 @@ [strongSelf stopVideoPlayback:false]; } }; + cropController.isVideoPlaying = ^bool{ + __strong TGPhotoEditorController *strongSelf = weakSelf; + if (strongSelf == nil) + return false; + return strongSelf->_isPlaying; + }; cropController.togglePlayback = ^{ __strong TGPhotoEditorController *strongSelf = weakSelf; if (strongSelf == nil || !strongSelf->_item.isVideo) @@ -2902,5 +2908,4 @@ return self.item.originalSize; } - @end diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 9285dca119..ec3b44da15 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -445,7 +445,7 @@ final class PeerInfoAvatarListContainerNode: ASDisplayNode { playerPosition = playerStatus.timestamp } - if let videoStartTimestamp = videoStartTimestamp { + if let videoStartTimestamp = videoStartTimestamp, false { playerPosition -= videoStartTimestamp if playerPosition < 0.0 { playerPosition = playerStatus.duration + playerPosition