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
@ -489,26 +489,37 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
|||||||
private var statusDisposable: Disposable?
|
private var statusDisposable: Disposable?
|
||||||
private var status: MediaPlayerStatus?
|
private var status: MediaPlayerStatus?
|
||||||
weak var pictureInPictureController: AVPictureInPictureController?
|
weak var pictureInPictureController: AVPictureInPictureController?
|
||||||
|
|
||||||
|
private var previousIsPlaying = false
|
||||||
init(node: UniversalVideoNode) {
|
init(node: UniversalVideoNode) {
|
||||||
self.node = node
|
self.node = node
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
|
var invalidatedStateOnce = false
|
||||||
self.statusDisposable = (self.node.status
|
self.statusDisposable = (self.node.status
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.status = status
|
strongSelf.status = status
|
||||||
strongSelf.pictureInPictureController?.invalidatePlaybackState()
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.statusDisposable?.dispose()
|
self.statusDisposable?.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, setPlaying playing: Bool) {
|
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, setPlaying playing: Bool) {
|
||||||
self.node.togglePlayPause()
|
self.node.togglePlayPause()
|
||||||
}
|
}
|
||||||
@ -517,7 +528,7 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
|||||||
guard let status = self.status else {
|
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: 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 {
|
public func pictureInPictureControllerIsPlaybackPaused(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
||||||
@ -652,6 +663,11 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
|||||||
mediaManager.galleryHiddenMediaManager.removeSource(hiddenMediaManagerIndex)
|
mediaManager.galleryHiddenMediaManager.removeSource(hiddenMediaManagerIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func invalidatePlaybackState() {
|
||||||
|
self.pictureInPictureController?.invalidatePlaybackState()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var videoNode: ASDisplayNode {
|
var videoNode: ASDisplayNode {
|
||||||
return self.node
|
return self.node
|
||||||
@ -675,6 +691,7 @@ private final class PictureInPictureContentImpl: NSObject, PictureInPictureConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, failedToStartPictureInPictureWithError error: Error) {
|
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, failedToStartPictureInPictureWithError error: Error) {
|
||||||
|
print(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func pictureInPictureControllerWillStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
public func pictureInPictureControllerWillStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
||||||
@ -1444,7 +1461,14 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||||||
videoNode.playbackCompleted = { [weak self, weak videoNode] in
|
videoNode.playbackCompleted = { [weak self, weak videoNode] in
|
||||||
Queue.mainQueue().async {
|
Queue.mainQueue().async {
|
||||||
item.playbackCompleted()
|
item.playbackCompleted()
|
||||||
|
|
||||||
if let strongSelf = self, !isAnimated {
|
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) {
|
if let snapshotView = videoNode?.view.snapshotView(afterScreenUpdates: false) {
|
||||||
videoNode?.view.addSubview(snapshotView)
|
videoNode?.view.addSubview(snapshotView)
|
||||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
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: "StringTransliteration", path: "../StringTransliteration"),
|
||||||
.package(name: "ManagedFile", path: "../ManagedFile"),
|
.package(name: "ManagedFile", path: "../ManagedFile"),
|
||||||
.package(name: "RangeSet", path: "../Utils/RangeSet"),
|
.package(name: "RangeSet", path: "../Utils/RangeSet"),
|
||||||
|
.package(name: "DarwinDirStat", path: "../Utils/DarwinDirStat"),
|
||||||
.package(name: "SSignalKit", path: "../SSignalKit"),
|
.package(name: "SSignalKit", path: "../SSignalKit"),
|
||||||
.package(name: "CryptoUtils", path: "../CryptoUtils")
|
.package(name: "CryptoUtils", path: "../CryptoUtils")
|
||||||
],
|
],
|
||||||
@ -35,6 +36,7 @@ let package = Package(
|
|||||||
.product(name: "RangeSet", package: "RangeSet", condition: nil),
|
.product(name: "RangeSet", package: "RangeSet", condition: nil),
|
||||||
.product(name: "sqlcipher", package: "sqlcipher", condition: nil),
|
.product(name: "sqlcipher", package: "sqlcipher", condition: nil),
|
||||||
.product(name: "StringTransliteration", package: "StringTransliteration", 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: "CryptoUtils", package: "CryptoUtils", condition: nil),
|
||||||
.product(name: "Crc32", package: "Crc32", condition: nil)],
|
.product(name: "Crc32", package: "Crc32", condition: nil)],
|
||||||
path: "Sources"),
|
path: "Sources"),
|
||||||
|
@ -229,3 +229,37 @@ func _internal_addChannelMembers(account: Account, peerId: PeerId, memberIds: [P
|
|||||||
return signal
|
return signal
|
||||||
|> switchToLatest
|
|> 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
|
||||||
|
}
|
||||||
|
@ -439,6 +439,10 @@ public extension TelegramEngine {
|
|||||||
public func addChannelMember(peerId: PeerId, memberId: PeerId) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), AddChannelMemberError> {
|
public func addChannelMember(peerId: PeerId, memberId: PeerId) -> Signal<(ChannelParticipant?, RenderedChannelParticipant), AddChannelMemberError> {
|
||||||
return _internal_addChannelMember(account: self.account, peerId: peerId, memberId: memberId)
|
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> {
|
public func addChannelMembers(peerId: PeerId, memberIds: [PeerId]) -> Signal<Void, AddChannelMemberError> {
|
||||||
return _internal_addChannelMembers(account: self.account, peerId: peerId, memberIds: memberIds)
|
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 {
|
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: 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 {
|
public func pictureInPictureControllerIsPlaybackPaused(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user