Various fixes

This commit is contained in:
Ilya Laktyushin
2022-10-22 13:15:41 +03:00
parent 384eb313bc
commit 84949750cd
2 changed files with 33 additions and 19 deletions

View File

@@ -86,7 +86,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
private var playerStatus: MediaPlayerStatus? {
didSet {
if self.playerStatus != oldValue {
self.updateStatus()
self.updateStatus(animator: nil)
}
}
}
@@ -465,9 +465,11 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
}
}
var previousVideoNode: UniversalVideoNode?
var updatedPlayerStatusSignal: Signal<MediaPlayerStatus?, NoError>?
if let telegramFile = updatedFile {
if updatedMedia {
previousVideoNode = strongSelf.videoNode
if let durationBlurColor = durationBlurColor {
if let durationBackgroundNode = strongSelf.durationBackgroundNode {
durationBackgroundNode.updateColor(color: durationBlurColor.0, enableBlur: durationBlurColor.1, transition: .immediate)
@@ -518,7 +520,11 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
}
}
}), content: NativeVideoContent(id: .message(item.message.stableId, telegramFile.fileId), fileReference: .message(message: MessageReference(item.message), media: telegramFile), streamVideo: streamVideo ? .conservative : .none, enableSound: false, fetchAutomatically: false, captureProtected: item.message.isCopyProtected()), priority: .embedded, autoplay: true)
let previousVideoNode = strongSelf.videoNode
if let previousVideoNode = previousVideoNode {
videoNode.bounds = previousVideoNode.bounds
videoNode.position = previousVideoNode.position
videoNode.transform = previousVideoNode.transform
}
strongSelf.videoNode = videoNode
strongSelf.insertSubnode(videoNode, belowSubnode: previousVideoNode ?? strongSelf.dateAndStatusNode)
videoNode.canAttachContent = strongSelf.shouldAcquireVideoContext
@@ -548,7 +554,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|> deliverOnMainQueue).start(next: { status in
if let strongSelf = self {
strongSelf.status = status
strongSelf.updateStatus()
strongSelf.updateStatus(animator: nil)
}
}))
}
@@ -658,12 +664,17 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
if let videoNode = strongSelf.videoNode {
videoNode.bounds = CGRect(origin: CGPoint(), size: videoFrame.size)
if imageScale != strongSelf.imageScale {
strongSelf.imageScale = imageScale
animation.animator.updateScale(layer: videoNode.layer, scale: imageScale, completion: nil)
}
strongSelf.imageScale = imageScale
animation.animator.updateScale(layer: videoNode.layer, scale: imageScale, completion: nil)
animation.animator.updatePosition(layer: videoNode.layer, position: displayVideoFrame.center, completion: nil)
videoNode.updateLayout(size: arguments.boundingSize, transition: animation.transition)
if let previousVideoNode = previousVideoNode {
animation.animator.updateScale(layer: previousVideoNode.layer, scale: imageScale, completion: nil)
animation.animator.updatePosition(layer: previousVideoNode.layer, position: displayVideoFrame.center, completion: nil)
}
}
animation.animator.updateFrame(layer: strongSelf.secretVideoPlaceholderBackground.layer, frame: displayVideoFrame, completion: nil)
@@ -677,7 +688,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
let applySecretPlaceholder = makeSecretPlaceholderLayout(arguments)
applySecretPlaceholder()
strongSelf.updateStatus()
strongSelf.updateStatus(animator: animation.animator)
if let telegramFile = updatedFile, previousAutomaticDownload != automaticDownload, automaticDownload {
strongSelf.fetchDisposable.set(messageMediaFileInteractiveFetched(context: item.context, message: item.message, file: telegramFile, userInitiated: false).start())
@@ -698,7 +709,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
}
}
private func updateStatus() {
private func updateStatus(animator: ControlledTransitionAnimator? = nil) {
guard let item = self.item, let status = self.status, let videoFrame = self.videoFrame else {
return
}
@@ -800,8 +811,17 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
}
let statusFrame = CGRect(origin: CGPoint(x: videoFrame.origin.x + floorToScreenPixels((videoFrame.size.width - 50.0) / 2.0), y: videoFrame.origin.y + floorToScreenPixels((videoFrame.size.height - 50.0) / 2.0)), size: CGSize(width: 50.0, height: 50.0))
self.statusNode?.frame = statusFrame
self.disappearingStatusNode?.frame = statusFrame
if let animator = animator {
if let statusNode = self.statusNode {
animator.updateFrame(layer: statusNode.layer, frame: statusFrame, completion: nil)
}
if let disappearingStatusNode = self.disappearingStatusNode {
animator.updateFrame(layer: disappearingStatusNode.layer, frame: statusFrame, completion: nil)
}
} else {
self.statusNode?.frame = statusFrame
self.disappearingStatusNode?.frame = statusFrame
}
var state: RadialStatusNodeState
switch status.mediaStatus {
@@ -1132,7 +1152,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
var updateTranscribeExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState, TranscribedText?) -> Void)?
private func transcribe() {
guard let context = self.item?.context, let message = self.item?.message else {
guard let context = self.item?.context, let message = self.item?.message, self.statusNode == nil else {
return
}