mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Native picture in picture support
This commit is contained in:
@@ -7,6 +7,7 @@ import TelegramCore
|
||||
import Display
|
||||
import TelegramAudio
|
||||
import UniversalMediaPlayer
|
||||
import AVFoundation
|
||||
|
||||
public protocol UniversalVideoContentNode: AnyObject {
|
||||
var ready: Signal<Void, NoError> { get }
|
||||
@@ -29,6 +30,7 @@ public protocol UniversalVideoContentNode: AnyObject {
|
||||
func removePlaybackCompleted(_ index: Int)
|
||||
func fetchControl(_ control: UniversalVideoNodeFetchControl)
|
||||
func notifyPlaybackControlsHidden(_ hidden: Bool)
|
||||
func setCanPlaybackWithoutHierarchy(_ canPlaybackWithoutHierarchy: Bool)
|
||||
}
|
||||
|
||||
public protocol UniversalVideoContent {
|
||||
@@ -332,4 +334,36 @@ public final class UniversalVideoNode: ASDisplayNode {
|
||||
self.decoration.tap()
|
||||
}
|
||||
}
|
||||
|
||||
public func getVideoLayer() -> AVSampleBufferDisplayLayer? {
|
||||
guard let contentNode = self.contentNode else {
|
||||
return nil
|
||||
}
|
||||
|
||||
func findVideoLayer(layer: CALayer) -> AVSampleBufferDisplayLayer? {
|
||||
if let layer = layer as? AVSampleBufferDisplayLayer {
|
||||
return layer
|
||||
}
|
||||
|
||||
if let sublayers = layer.sublayers {
|
||||
for sublayer in sublayers {
|
||||
if let result = findVideoLayer(layer: sublayer) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return findVideoLayer(layer: contentNode.layer)
|
||||
}
|
||||
|
||||
public func setCanPlaybackWithoutHierarchy(_ canPlaybackWithoutHierarchy: Bool) {
|
||||
self.manager.withUniversalVideoContent(id: self.content.id, { contentNode in
|
||||
if let contentNode = contentNode {
|
||||
contentNode.setCanPlaybackWithoutHierarchy(canPlaybackWithoutHierarchy)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user