mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-01 07:57:01 +00:00
Fix youtube video controls visibility toggling
This commit is contained in:
parent
0e9412fbc9
commit
32b7ac2a27
@ -29,6 +29,7 @@ public protocol UniversalVideoContentNode: class {
|
||||
func addPlaybackCompleted(_ f: @escaping () -> Void) -> Int
|
||||
func removePlaybackCompleted(_ index: Int)
|
||||
func fetchControl(_ control: UniversalVideoNodeFetchControl)
|
||||
func notifyPlaybackControlsHidden(_ hidden: Bool)
|
||||
}
|
||||
|
||||
public protocol UniversalVideoContent {
|
||||
@ -319,6 +320,14 @@ public final class UniversalVideoNode: ASDisplayNode {
|
||||
})
|
||||
}
|
||||
|
||||
public func notifyPlaybackControlsHidden(_ hidden: Bool) {
|
||||
self.manager.withUniversalVideoContent(id: self.content.id, { contentNode in
|
||||
if let contentNode = contentNode {
|
||||
contentNode.notifyPlaybackControlsHidden(hidden)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@objc private func tapGesture(_ recognizer: UITapGestureRecognizer) {
|
||||
if case .ended = recognizer.state {
|
||||
self.decoration.tap()
|
||||
|
@ -265,6 +265,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
private let overlayContentNode: UniversalVideoGalleryItemOverlayNode
|
||||
|
||||
private var videoNode: UniversalVideoNode?
|
||||
private var videoNodeUserInteractionEnabled: Bool = false
|
||||
private var videoFramePreview: FramePreview?
|
||||
private var pictureInPictureNode: UniversalVideoGalleryItemPictureInPictureNode?
|
||||
private let statusButtonNode: HighlightableButtonNode
|
||||
@ -555,6 +556,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
}
|
||||
}
|
||||
self.videoNode = videoNode
|
||||
self.videoNodeUserInteractionEnabled = disablePlayerControls || forceEnableUserInteraction
|
||||
videoNode.isUserInteractionEnabled = disablePlayerControls || forceEnableUserInteraction
|
||||
videoNode.backgroundColor = videoNode.ownsContentNode ? UIColor.black : UIColor(rgb: 0x333335)
|
||||
if item.fromPlayingVideo {
|
||||
@ -680,6 +682,10 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
if !content.enableSound {
|
||||
isPaused = false
|
||||
}
|
||||
} else {
|
||||
strongSelf.updateControlsVisibility(true)
|
||||
strongSelf.controlsTimer?.invalidate()
|
||||
strongSelf.controlsTimer = nil
|
||||
}
|
||||
}
|
||||
seekable = value.duration >= 30.0
|
||||
@ -795,6 +801,9 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
override func controlsVisibilityUpdated(isVisible: Bool) {
|
||||
self.controlsTimer?.invalidate()
|
||||
self.controlsTimer = nil
|
||||
|
||||
self.videoNode?.isUserInteractionEnabled = isVisible ? self.videoNodeUserInteractionEnabled : false
|
||||
self.videoNode?.notifyPlaybackControlsHidden(!isVisible)
|
||||
}
|
||||
|
||||
private func updateDisplayPlaceholder(_ displayPlaceholder: Bool) {
|
||||
|
@ -451,4 +451,7 @@ private final class NativeVideoContentNode: ASDisplayNode, UniversalVideoContent
|
||||
self.postbox.mediaBox.cancelInteractiveResourceFetch(self.fileReference.media.resource)
|
||||
}
|
||||
}
|
||||
|
||||
func notifyPlaybackControlsHidden(_ hidden: Bool) {
|
||||
}
|
||||
}
|
||||
|
@ -448,4 +448,7 @@ private final class PlatformVideoContentNode: ASDisplayNode, UniversalVideoConte
|
||||
|
||||
func fetchControl(_ control: UniversalVideoNodeFetchControl) {
|
||||
}
|
||||
|
||||
func notifyPlaybackControlsHidden(_ hidden: Bool) {
|
||||
}
|
||||
}
|
||||
|
@ -287,5 +287,8 @@ private final class SystemVideoContentNode: ASDisplayNode, UniversalVideoContent
|
||||
|
||||
func fetchControl(_ control: UniversalVideoNodeFetchControl) {
|
||||
}
|
||||
|
||||
func notifyPlaybackControlsHidden(_ hidden: Bool) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,4 +211,10 @@ final class WebEmbedPlayerNode: ASDisplayNode, WKNavigationDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func notifyPlaybackControlsHidden(_ hidden: Bool) {
|
||||
if impl is YoutubeEmbedImplementation {
|
||||
self.webView.isUserInteractionEnabled = !hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,4 +184,8 @@ final class WebEmbedVideoContentNode: ASDisplayNode, UniversalVideoContentNode {
|
||||
|
||||
func fetchControl(_ control: UniversalVideoNodeFetchControl) {
|
||||
}
|
||||
|
||||
func notifyPlaybackControlsHidden(_ hidden: Bool) {
|
||||
self.playerNode.notifyPlaybackControlsHidden(hidden)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user