mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '45e7cc9d284bfc5e65c03b82719aa847254ce513'
This commit is contained in:
commit
9fe022a499
@ -490,18 +490,29 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
||||
private var status: MediaPlayerStatus?
|
||||
weak var pictureInPictureController: AVPictureInPictureController?
|
||||
|
||||
private var previousIsPlaying = false
|
||||
init(node: UniversalVideoNode) {
|
||||
self.node = node
|
||||
|
||||
super.init()
|
||||
|
||||
var invalidatedStateOnce = false
|
||||
self.statusDisposable = (self.node.status
|
||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.status = status
|
||||
if let status {
|
||||
let isPlaying = status.status == .playing
|
||||
if !invalidatedStateOnce {
|
||||
invalidatedStateOnce = true
|
||||
strongSelf.pictureInPictureController?.invalidatePlaybackState()
|
||||
} else if strongSelf.previousIsPlaying != isPlaying {
|
||||
strongSelf.previousIsPlaying = isPlaying
|
||||
strongSelf.pictureInPictureController?.invalidatePlaybackState()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -517,7 +528,7 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
||||
guard let status = self.status else {
|
||||
return CMTimeRange(start: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(30.0)), duration: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(30.0)))
|
||||
}
|
||||
return CMTimeRange(start: CMTime(seconds: status.timestamp, preferredTimescale: CMTimeScale(30.0)), duration: CMTime(seconds: status.duration, preferredTimescale: CMTimeScale(30.0)))
|
||||
return CMTimeRange(start: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(30.0)), duration: CMTime(seconds: status.duration - status.timestamp, preferredTimescale: CMTimeScale(30.0)))
|
||||
}
|
||||
|
||||
public func pictureInPictureControllerIsPlaybackPaused(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
||||
@ -653,6 +664,11 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
||||
}
|
||||
}
|
||||
|
||||
func invalidatePlaybackState() {
|
||||
self.pictureInPictureController?.invalidatePlaybackState()
|
||||
}
|
||||
|
||||
|
||||
var videoNode: ASDisplayNode {
|
||||
return self.node
|
||||
}
|
||||
@ -675,6 +691,7 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
||||
}
|
||||
|
||||
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, failedToStartPictureInPictureWithError error: Error) {
|
||||
print(error)
|
||||
}
|
||||
|
||||
public func pictureInPictureControllerWillStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
||||
@ -1444,7 +1461,14 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
videoNode.playbackCompleted = { [weak self, weak videoNode] in
|
||||
Queue.mainQueue().async {
|
||||
item.playbackCompleted()
|
||||
|
||||
if let strongSelf = self, !isAnimated {
|
||||
if #available(iOS 15.0, *) {
|
||||
if let pictureInPictureContent = strongSelf.pictureInPictureContent as? PictureInPictureContentImpl {
|
||||
pictureInPictureContent.invalidatePlaybackState()
|
||||
}
|
||||
}
|
||||
|
||||
if let snapshotView = videoNode?.view.snapshotView(afterScreenUpdates: false) {
|
||||
videoNode?.view.addSubview(snapshotView)
|
||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
||||
|
@ -21,6 +21,7 @@ let package = Package(
|
||||
.package(name: "StringTransliteration", path: "../StringTransliteration"),
|
||||
.package(name: "ManagedFile", path: "../ManagedFile"),
|
||||
.package(name: "RangeSet", path: "../Utils/RangeSet"),
|
||||
.package(name: "DarwinDirStat", path: "../Utils/DarwinDirStat"),
|
||||
.package(name: "SSignalKit", path: "../SSignalKit"),
|
||||
.package(name: "CryptoUtils", path: "../CryptoUtils")
|
||||
],
|
||||
@ -35,6 +36,7 @@ let package = Package(
|
||||
.product(name: "RangeSet", package: "RangeSet", condition: nil),
|
||||
.product(name: "sqlcipher", package: "sqlcipher", condition: nil),
|
||||
.product(name: "StringTransliteration", package: "StringTransliteration", condition: nil),
|
||||
.product(name: "DarwinDirStat", package: "DarwinDirStat", condition: nil),
|
||||
.product(name: "CryptoUtils", package: "CryptoUtils", condition: nil),
|
||||
.product(name: "Crc32", package: "Crc32", condition: nil)],
|
||||
path: "Sources"),
|
||||
|
@ -229,3 +229,37 @@ func _internal_addChannelMembers(account: Account, peerId: PeerId, memberIds: [P
|
||||
return signal
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
|
||||
public enum SendBotRequestedPeerError {
|
||||
case generic
|
||||
}
|
||||
|
||||
func _internal_sendBotRequestedPeer(account: Account, peerId: PeerId, messageId: MessageId, buttonId: Int32, requestedPeerId: PeerId) -> Signal<Void, SendBotRequestedPeerError> {
|
||||
let signal = account.postbox.transaction { transaction -> Signal<Void, SendBotRequestedPeerError> in
|
||||
|
||||
|
||||
if let peer = transaction.getPeer(peerId), let requestedPeer = transaction.getPeer(requestedPeerId) {
|
||||
|
||||
let inputPeer = apiInputPeer(peer)
|
||||
let inputRequestedPeer = apiInputPeer(requestedPeer)
|
||||
|
||||
if let inputPeer = inputPeer, let inputRequestedPeer = inputRequestedPeer {
|
||||
let signal = account.network.request(Api.functions.messages.sendBotRequestedPeer(peer: inputPeer, msgId: messageId.id, buttonId: buttonId, requestedPeer: inputRequestedPeer))
|
||||
|> mapError { error -> SendBotRequestedPeerError in
|
||||
return .generic
|
||||
}
|
||||
|> map { result in
|
||||
account.stateManager.addUpdates(result)
|
||||
}
|
||||
return signal
|
||||
}
|
||||
|
||||
}
|
||||
return .single(Void())
|
||||
}
|
||||
|> castError(SendBotRequestedPeerError.self)
|
||||
|
||||
return signal
|
||||
|> switchToLatest
|
||||
}
|
||||
|
@ -440,6 +440,10 @@ public extension TelegramEngine {
|
||||
return _internal_addChannelMember(account: self.account, peerId: peerId, memberId: memberId)
|
||||
}
|
||||
|
||||
public func sendBotRequestedPeer(messageId: MessageId, buttonId: Int32, requestedPeerId: PeerId) -> Signal<Void, SendBotRequestedPeerError> {
|
||||
return _internal_sendBotRequestedPeer(account: self.account, peerId: messageId.peerId, messageId: messageId, buttonId: buttonId, requestedPeerId: requestedPeerId)
|
||||
}
|
||||
|
||||
public func addChannelMembers(peerId: PeerId, memberIds: [PeerId]) -> Signal<Void, AddChannelMemberError> {
|
||||
return _internal_addChannelMembers(account: self.account, peerId: peerId, memberIds: memberIds)
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ public final class OverlayUniversalVideoNode: OverlayMediaItemNode, AVPictureInP
|
||||
guard let status = self.status else {
|
||||
return CMTimeRange(start: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(30.0)), duration: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(30.0)))
|
||||
}
|
||||
return CMTimeRange(start: CMTime(seconds: status.timestamp, preferredTimescale: CMTimeScale(30.0)), duration: CMTime(seconds: status.duration, preferredTimescale: CMTimeScale(30.0)))
|
||||
return CMTimeRange(start: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(30.0)), duration: CMTime(seconds: status.duration, preferredTimescale: CMTimeScale(30.0)))
|
||||
}
|
||||
|
||||
public func pictureInPictureControllerIsPlaybackPaused(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
||||
|
Loading…
x
Reference in New Issue
Block a user