Updated Youtube chrome removal

Fixed group sticker pack settings button showing for non-admins
This commit is contained in:
Ilya Laktyushin 2018-11-06 22:03:04 +04:00
parent a3c55e7c0d
commit 41a0f302f3
12 changed files with 181 additions and 56 deletions

View File

@ -55,12 +55,12 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
return panelHeight
}
override func animateIn(fromHeight: CGFloat, transition: ContainedViewLayoutTransition) {
override func animateIn(fromHeight: CGFloat, previousContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition) {
self.deleteButton.alpha = 1.0
self.actionButton.alpha = 1.0
}
override func animateOut(toHeight: CGFloat, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
override func animateOut(toHeight: CGFloat, nextContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
self.deleteButton.alpha = 0.0
self.actionButton.alpha = 0.0
}

View File

@ -213,7 +213,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode {
self.dateNode.maximumNumberOfLines = 1
self.dateNode.isLayerBacked = true
self.dateNode.displaysAsynchronously = false
self.backwardButton = HighlightableButtonNode()
self.backwardButton.isHidden = true
self.backwardButton.setImage(backwardImage, for: [])
@ -254,7 +254,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode {
self.addSubnode(self.textNode)
self.addSubnode(self.authorNameNode)
self.addSubnode(self.dateNode)
self.addSubnode(self.backwardButton)
self.addSubnode(self.forwardButton)
self.addSubnode(self.playbackControlButton)
@ -448,9 +448,12 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode {
return panelHeight
}
override func animateIn(fromHeight: CGFloat, transition: ContainedViewLayoutTransition) {
override func animateIn(fromHeight: CGFloat, previousContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition) {
if let scrubberView = self.scrubberView, scrubberView.superview == self.view {
transition.animatePositionAdditive(layer: scrubberView.layer, offset: CGPoint(x: 0.0, y: self.bounds.height - fromHeight))
if let previousContentNode = previousContentNode as? ChatItemGalleryFooterContentNode, previousContentNode.scrubberView != nil {
} else {
transition.animatePositionAdditive(layer: scrubberView.layer, offset: CGPoint(x: 0.0, y: self.bounds.height - fromHeight))
}
scrubberView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15)
}
transition.animatePositionAdditive(node: self.textNode, offset: CGPoint(x: 0.0, y: self.bounds.height - fromHeight))
@ -459,12 +462,19 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode {
self.authorNameNode.alpha = 1.0
self.deleteButton.alpha = 1.0
self.actionButton.alpha = 1.0
self.backwardButton.alpha = 1.0
self.forwardButton.alpha = 1.0
self.statusNode.alpha = 1.0
self.playbackControlButton.alpha = 1.0
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15)
}
override func animateOut(toHeight: CGFloat, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
override func animateOut(toHeight: CGFloat, nextContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
if let scrubberView = self.scrubberView, scrubberView.superview == self.view {
transition.updateFrame(view: scrubberView, frame: scrubberView.frame.offsetBy(dx: 0.0, dy: self.bounds.height - toHeight))
if let nextContentNode = nextContentNode as? ChatItemGalleryFooterContentNode, nextContentNode.scrubberView != nil {
} else {
transition.updateFrame(view: scrubberView, frame: scrubberView.frame.offsetBy(dx: 0.0, dy: self.bounds.height - toHeight))
}
scrubberView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15)
}
transition.updateFrame(node: self.textNode, frame: self.textNode.frame.offsetBy(dx: 0.0, dy: self.bounds.height - toHeight))
@ -473,6 +483,10 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode {
self.authorNameNode.alpha = 0.0
self.deleteButton.alpha = 0.0
self.actionButton.alpha = 0.0
self.backwardButton.alpha = 0.0
self.forwardButton.alpha = 0.0
self.statusNode.alpha = 0.0
self.playbackControlButton.alpha = 0.0
self.textNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, completion: { _ in
completion()
})

View File

@ -68,7 +68,7 @@ enum ChatMediaInputGridEntryIndex: Equatable, Comparable {
enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
case search(theme: PresentationTheme, strings: PresentationStrings)
case peerSpecificSetup(theme: PresentationTheme, strings: PresentationStrings, dismissed: Bool)
case sticker(index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, stickerPackInfo: StickerPackCollectionInfo?, theme: PresentationTheme)
case sticker(index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, stickerPackInfo: StickerPackCollectionInfo?, canManagePeerSpecificPack: Bool?, theme: PresentationTheme)
var index: ChatMediaInputGridEntryIndex {
switch self {
@ -76,7 +76,7 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
return .search
case let .peerSpecificSetup(_, _, dismissed):
return .peerSpecificSetup(dismissed: dismissed)
case let .sticker(index, _, _, _):
case let .sticker(index, _, _, _, _):
return .collectionIndex(index)
}
}
@ -105,8 +105,8 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
} else {
return false
}
case let .sticker(lhsIndex, lhsStickerItem, lhsStickerPackInfo, lhsTheme):
if case let .sticker(rhsIndex, rhsStickerItem, rhsStickerPackInfo, rhsTheme) = rhs {
case let .sticker(lhsIndex, lhsStickerItem, lhsStickerPackInfo, lhsCanManagePeerSpecificPack, lhsTheme):
if case let .sticker(rhsIndex, rhsStickerItem, rhsStickerPackInfo, rhsCanManagePeerSpecificPack, rhsTheme) = rhs {
if lhsIndex != rhsIndex {
return false
}
@ -116,6 +116,9 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
if lhsStickerPackInfo != rhsStickerPackInfo {
return false
}
if lhsCanManagePeerSpecificPack != rhsCanManagePeerSpecificPack {
return false
}
if lhsTheme !== rhsTheme {
return false
}
@ -142,8 +145,8 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
}, dismiss: dismissed ? nil : {
inputNodeInteraction.dismissPeerSpecificSettings()
})
case let .sticker(index, stickerItem, stickerPackInfo, theme):
return ChatMediaInputStickerGridItem(account: account, collectionId: index.collectionId, stickerPackInfo: stickerPackInfo, index: index, stickerItem: stickerItem, interfaceInteraction: interfaceInteraction, inputNodeInteraction: inputNodeInteraction, theme: theme, selected: { })
case let .sticker(index, stickerItem, stickerPackInfo, canManagePeerSpecificPack, theme):
return ChatMediaInputStickerGridItem(account: account, collectionId: index.collectionId, stickerPackInfo: stickerPackInfo, index: index, stickerItem: stickerItem, canManagePeerSpecificPack: canManagePeerSpecificPack, interfaceInteraction: interfaceInteraction, inputNodeInteraction: inputNodeInteraction, theme: theme, selected: { })
}
}
}

View File

@ -210,7 +210,7 @@ private func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers:
savedStickerIds.insert(item.file.fileId.id)
let index = ItemCollectionItemIndex(index: Int32(i), id: item.file.fileId.id)
let stickerItem = StickerPackItem(index: index, file: item.file, indexKeys: [])
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -3, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, theme: theme))
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -3, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: nil, theme: theme))
}
}
}
@ -226,14 +226,19 @@ private func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers:
if !savedStickerIds.contains(mediaId.id) {
let index = ItemCollectionItemIndex(index: Int32(i), id: mediaId.id)
let stickerItem = StickerPackItem(index: index, file: file, indexKeys: [])
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -2, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, theme: theme))
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -2, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: nil, theme: theme))
addedCount += 1
}
}
}
}
if peerSpecificPack == nil, case .available(_, false) = canInstallPeerSpecificPack {
var canManagePeerSpecificPack = false
if case .available(_, false) = canInstallPeerSpecificPack {
canManagePeerSpecificPack = true
}
if peerSpecificPack == nil && canManagePeerSpecificPack {
entries.append(.peerSpecificSetup(theme: theme, strings: strings, dismissed: false))
}
@ -244,7 +249,7 @@ private func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers:
if let item = peerSpecificPack.items[i] as? StickerPackItem {
let index = ItemCollectionItemIndex(index: Int32(i), id: item.file.fileId.id)
let stickerItem = StickerPackItem(index: index, file: item.file, indexKeys: [])
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -1, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, theme: theme))
entries.append(.sticker(index: ItemCollectionViewEntryIndex(collectionIndex: -1, collectionId: packInfo.id, itemIndex: index), stickerItem: stickerItem, stickerPackInfo: packInfo, canManagePeerSpecificPack: canManagePeerSpecificPack, theme: theme))
}
}
}
@ -252,7 +257,7 @@ private func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers:
for entry in view.entries {
if let item = entry.item as? StickerPackItem {
entries.append(.sticker(index: entry.index, stickerItem: item, stickerPackInfo: stickerPackInfos[entry.index.collectionId], theme: theme))
entries.append(.sticker(index: entry.index, stickerItem: item, stickerPackInfo: stickerPackInfos[entry.index.collectionId], canManagePeerSpecificPack: false, theme: theme))
}
}

View File

@ -8,6 +8,7 @@ import Postbox
final class ChatMediaInputStickerGridSection: GridSection {
let collectionId: ItemCollectionId
let collectionInfo: StickerPackCollectionInfo?
let canManagePeerSpecificPack: Bool?
let interaction: ChatMediaInputNodeInteraction
let theme: PresentationTheme
let height: CGFloat = 26.0
@ -16,9 +17,10 @@ final class ChatMediaInputStickerGridSection: GridSection {
return self.collectionId.hashValue
}
init(collectionId: ItemCollectionId, collectionInfo: StickerPackCollectionInfo?, theme: PresentationTheme, interaction: ChatMediaInputNodeInteraction) {
init(collectionId: ItemCollectionId, collectionInfo: StickerPackCollectionInfo?, canManagePeerSpecificPack: Bool?, theme: PresentationTheme, interaction: ChatMediaInputNodeInteraction) {
self.collectionId = collectionId
self.collectionInfo = collectionInfo
self.canManagePeerSpecificPack = canManagePeerSpecificPack
self.theme = theme
self.interaction = interaction
}
@ -32,7 +34,7 @@ final class ChatMediaInputStickerGridSection: GridSection {
}
func node() -> ASDisplayNode {
return ChatMediaInputStickerGridSectionNode(collectionInfo: self.collectionInfo, theme: self.theme, interaction: self.interaction)
return ChatMediaInputStickerGridSectionNode(collectionInfo: self.collectionInfo, canManagePeerSpecificPack: self.canManagePeerSpecificPack, theme: self.theme, interaction: self.interaction)
}
}
@ -43,12 +45,12 @@ final class ChatMediaInputStickerGridSectionNode: ASDisplayNode {
let setupNode: HighlightableButtonNode?
let interaction: ChatMediaInputNodeInteraction
init(collectionInfo: StickerPackCollectionInfo?, theme: PresentationTheme, interaction: ChatMediaInputNodeInteraction) {
init(collectionInfo: StickerPackCollectionInfo?, canManagePeerSpecificPack: Bool?, theme: PresentationTheme, interaction: ChatMediaInputNodeInteraction) {
self.interaction = interaction
self.titleNode = ASTextNode()
self.titleNode.isLayerBacked = true
if collectionInfo?.id.namespace == ChatMediaInputPanelAuxiliaryNamespace.peerSpecific.rawValue {
if collectionInfo?.id.namespace == ChatMediaInputPanelAuxiliaryNamespace.peerSpecific.rawValue, let canManage = canManagePeerSpecificPack, canManage {
let setupNode = HighlightableButtonNode()
setupNode.setImage(PresentationResourcesChat.chatInputMediaPanelGridSetupImage(theme), for: [])
self.setupNode = setupNode
@ -76,7 +78,7 @@ final class ChatMediaInputStickerGridSectionNode: ASDisplayNode {
self.titleNode.frame = CGRect(origin: CGPoint(x: 12.0, y: 9.0), size: titleSize)
if let setupNode = self.setupNode {
setupNode.frame = CGRect(origin: CGPoint(x: bounds.width - 12.0 - 16.0, y: 0.0), size: CGSize(width: 16.0, height: 26.0))
setupNode.frame = CGRect(origin: CGPoint(x: bounds.width - 12.0 - 16.0, y: 2.0), size: CGSize(width: 16.0, height: 26.0))
}
}
@ -95,7 +97,7 @@ final class ChatMediaInputStickerGridItem: GridItem {
let section: GridSection?
init(account: Account, collectionId: ItemCollectionId, stickerPackInfo: StickerPackCollectionInfo?, index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, interfaceInteraction: ChatControllerInteraction?, inputNodeInteraction: ChatMediaInputNodeInteraction, theme: PresentationTheme, selected: @escaping () -> Void) {
init(account: Account, collectionId: ItemCollectionId, stickerPackInfo: StickerPackCollectionInfo?, index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, canManagePeerSpecificPack: Bool?, interfaceInteraction: ChatControllerInteraction?, inputNodeInteraction: ChatMediaInputNodeInteraction, theme: PresentationTheme, selected: @escaping () -> Void) {
self.account = account
self.index = index
self.stickerItem = stickerItem
@ -105,7 +107,7 @@ final class ChatMediaInputStickerGridItem: GridItem {
if collectionId.namespace == ChatMediaInputPanelAuxiliaryNamespace.savedStickers.rawValue {
self.section = nil
} else {
self.section = ChatMediaInputStickerGridSection(collectionId: collectionId, collectionInfo: stickerPackInfo, theme: theme, interaction: inputNodeInteraction)
self.section = ChatMediaInputStickerGridSection(collectionId: collectionId, collectionInfo: stickerPackInfo, canManagePeerSpecificPack: canManagePeerSpecificPack, theme: theme, interaction: inputNodeInteraction)
}
}

View File

@ -1,14 +1,23 @@
import Foundation
import AsyncDisplayKit
import UIKit
import SwiftSignalKit
import TelegramCore
import Postbox
import Display
private let textFont = Font.regular(13.0)
final class ChatVideoGalleryItemScrubberView: UIView {
private let leftTimestampNode: MediaPlayerTimeTextNode
private let rightTimestampNode: MediaPlayerTimeTextNode
private let fileSizeNode: ASTextNode
private let scrubberNode: MediaPlayerScrubbingNode
private var playbackStatus: MediaPlayerStatus?
private var fetchStatusDisposable = MetaDisposable()
var hideWhenDurationIsUnknown = false {
didSet {
if self.hideWhenDurationIsUnknown {
@ -39,6 +48,11 @@ final class ChatVideoGalleryItemScrubberView: UIView {
self.rightTimestampNode.alignment = .right
self.rightTimestampNode.mode = .reversed
self.fileSizeNode = ASTextNode()
self.fileSizeNode.maximumNumberOfLines = 1
self.fileSizeNode.isLayerBacked = true
self.fileSizeNode.displaysAsynchronously = false
super.init(frame: frame)
self.scrubberNode.seek = { [weak self] timestamp in
@ -69,6 +83,7 @@ final class ChatVideoGalleryItemScrubberView: UIView {
self.addSubnode(self.scrubberNode)
self.addSubnode(self.leftTimestampNode)
self.addSubnode(self.rightTimestampNode)
self.addSubnode(self.fileSizeNode)
}
required init?(coder aDecoder: NSCoder) {
@ -93,6 +108,33 @@ final class ChatVideoGalleryItemScrubberView: UIView {
self.scrubberNode.bufferingStatus = status
}
func setFetchStatusSignal(_ fetchStatus: Signal<MediaResourceStatus, NoError>?, strings: PresentationStrings, fileSize: Int?) {
if let fileSize = fileSize {
if let fetchStatus = fetchStatus {
self.fetchStatusDisposable.set((fetchStatus
|> deliverOnMainQueue).start(next: { [weak self] status in
if let strongSelf = self {
var text: String
switch status {
case .Remote:
text = dataSizeString(fileSize, forceDecimal: true)
case let .Fetching(_, progress):
text = strings.DownloadingStatus(dataSizeString(Int64(Float(fileSize) * progress), forceDecimal: true), dataSizeString(fileSize, forceDecimal: true)).0
default:
text = ""
}
strongSelf.fileSizeNode.attributedText = NSAttributedString(string: text, font: textFont, textColor: .white)
strongSelf.layoutSubviews()
}
}))
} else {
self.fileSizeNode.attributedText = NSAttributedString(string: dataSizeString(fileSize, forceDecimal: true), font: textFont, textColor: .white)
}
} else {
self.fileSizeNode.attributedText = nil
}
}
override func layoutSubviews() {
super.layoutSubviews()
@ -106,6 +148,8 @@ final class ChatVideoGalleryItemScrubberView: UIView {
self.leftTimestampNode.frame = CGRect(origin: CGPoint(x: 6.0, y: 22.0), size: CGSize(width: 60.0, height: 20.0))
self.rightTimestampNode.frame = CGRect(origin: CGPoint(x: size.width - 60.0 - 6.0, y: 22.0), size: CGSize(width: 60.0, height: 20.0))
let fileSize = self.fileSizeNode.measure(size)
self.fileSizeNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - fileSize.width) / 2.0), y: 22.0), size: fileSize)
self.scrubberNode.frame = CGRect(origin: CGPoint(x: 6.0, y: 6.0), size: CGSize(width: size.width - 6.0 * 2.0, height: scrubberHeight))
}
}

View File

@ -23,10 +23,10 @@ open class GalleryFooterContentNode: ASDisplayNode {
return 0.0
}
func animateIn(fromHeight: CGFloat, transition: ContainedViewLayoutTransition) {
func animateIn(fromHeight: CGFloat, previousContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition) {
}
func animateOut(toHeight: CGFloat, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
func animateOut(toHeight: CGFloat, nextContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
completion()
}
}

View File

@ -49,8 +49,8 @@ final class GalleryFooterNode: ASDisplayNode {
transition.updateFrame(node: footerContentNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - backgroundHeight), size: CGSize(width: layout.size.width, height: backgroundHeight)))
if let removeCurrentFooterContentNode = removeCurrentFooterContentNode {
let contentTransition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring)
footerContentNode.animateIn(fromHeight: removeCurrentFooterContentNode.bounds.height, transition: contentTransition)
removeCurrentFooterContentNode.animateOut(toHeight: backgroundHeight, transition: contentTransition, completion: { [weak removeCurrentFooterContentNode] in
footerContentNode.animateIn(fromHeight: removeCurrentFooterContentNode.bounds.height, previousContentNode: removeCurrentFooterContentNode, transition: contentTransition)
removeCurrentFooterContentNode.animateOut(toHeight: backgroundHeight, nextContentNode: footerContentNode, transition: contentTransition, completion: { [weak removeCurrentFooterContentNode] in
removeCurrentFooterContentNode?.removeFromSupernode()
})
contentTransition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - backgroundHeight), size: CGSize(width: layout.size.width, height: backgroundHeight)))

View File

@ -31,6 +31,37 @@ function tick() {
progress.style.opacity = "0";
}
var pause = document.getElementsByClassName("ytp-pause-overlay")[0];
if (pause != null) {
pause.style.display = "none";
pause.style.opacity = "0";
}
var chrome = document.getElementsByClassName("ytp-chrome-top")[0];
if (chrome != null) {
chrome.style.display = "none";
chrome.style.opacity = "0";
}
var paid = document.getElementsByClassName("ytp-paid-content-overlay")[0];
if (paid != null) {
paid.style.display = "none";
paid.style.opacity = "0";
}
var end = document.getElementsByClassName("html5-endscreen")[0];
if (end != null) {
end.style.display = "none";
end.style.opacity = "0";
}
var elements = document.getElementsByClassName("ytp-ce-element");
for (var i = 0; i < elements.length; i++) {
var element = elements[i]
element.style.display = "none";
element.style.opacity = "0";
}
var video = document.getElementsByTagName("video")[0];
if (video != null) {
video.setAttribute("webkit-playsinline", "");

View File

@ -114,7 +114,7 @@ final class SecureIdDocumentGalleryFooterContentNode: GalleryFooterContentNode {
return panelHeight
}
override func animateIn(fromHeight: CGFloat, transition: ContainedViewLayoutTransition) {
override func animateIn(fromHeight: CGFloat, previousContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition) {
transition.animatePositionAdditive(node: self.textNode, offset: CGPoint(x: 0.0, y: self.bounds.size.height - fromHeight))
self.textNode.alpha = 1.0
self.dateNode.alpha = 1.0
@ -123,7 +123,7 @@ final class SecureIdDocumentGalleryFooterContentNode: GalleryFooterContentNode {
self.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15)
}
override func animateOut(toHeight: CGFloat, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
override func animateOut(toHeight: CGFloat, nextContentNode: GalleryFooterContentNode, transition: ContainedViewLayoutTransition, completion: @escaping () -> Void) {
transition.updateFrame(node: self.textNode, frame: self.textNode.frame.offsetBy(dx: 0.0, dy: self.bounds.height - toHeight))
self.textNode.alpha = 0.0
self.dateNode.alpha = 0.0

View File

@ -153,6 +153,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
private var didPause = false
private var isPaused = true
private var requiresDownload = false
private var item: UniversalVideoGalleryItem?
private let statusDisposable = MetaDisposable()
@ -224,14 +226,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
switch fetchStatus {
case .Fetching:
fetchControls.cancel()
// if let cancel = fetchControls.with({ return $0?.cancel }) {
// cancel()
// }
case .Remote:
fetchControls.fetch()
// if let fetch = fetchControls.with({ return $0?.fetch }) {
// fetch()
// }
case .Local:
break
}
@ -318,7 +314,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
self.scrubberView.setBufferingStatusSignal(videoNode.bufferingStatus)
var mediaFileStatus: Signal<MediaResourceStatus?, NoError>
var requiresDownload = true
var mediaFileStatus: Signal<MediaResourceStatus?, NoError> = .single(nil)
if let contentInfo = item.contentInfo, case let .message(message) = contentInfo {
var file: TelegramMediaFile?
for m in message.media {
@ -328,9 +325,11 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
}
}
if let file = file {
mediaFileStatus = messageMediaFileStatus(account: item.account, messageId: message.id, file: file)
|> map(Optional.init)
let status = messageMediaFileStatus(account: item.account, messageId: message.id, file: file)
self.scrubberView.setFetchStatusSignal(status, strings: self.strings, fileSize: file.size)
self.requiresDownload = !isMediaStreamable(message: message, media: file)
mediaFileStatus = status |> map(Optional.init)
self.fetchControls = FetchControls(fetch: { [weak self] in
if let strongSelf = self {
strongSelf.fetchDisposable.set(messageMediaFileInteractiveFetched(account: item.account, message: message, file: file, userInitiated: true).start())
@ -338,18 +337,9 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
}, cancel: {
messageMediaFileCancelInteractiveFetch(account: item.account, messageId: message.id, file: file)
})
} else {
mediaFileStatus = .single(nil)
}
} else {
mediaFileStatus = .single(nil)
}
// else if case let .webPage(webPage, file) = contentInfo {
//
// }
//messageFileMediaResourceStatus(account: item.account, file: item.content., message: item.a, isRecentActions: false)
self.statusDisposable.set((combineLatest(videoNode.status, mediaFileStatus) |> deliverOnMainQueue).start(next: { [weak self] value, fetchStatus in
if let strongSelf = self {
var initialBuffering = false
@ -390,17 +380,34 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
seekable = value.duration >= 45.0
}
var fetching = false
if initialBuffering {
strongSelf.statusNode.transitionToState(.progress(color: .white, lineWidth: nil, value: nil, cancelEnabled: false), animated: false, completion: {})
} else {
strongSelf.statusNode.transitionToState(.play(.white), animated: false, completion: {})
var state: RadialStatusNodeState = .play(.white)
if let fetchStatus = fetchStatus {
if strongSelf.requiresDownload {
switch fetchStatus {
case .Remote:
state = .download(.white)
case let .Fetching(_, progress):
fetching = true
isPaused = true
state = .progress(color: .white, lineWidth: nil, value: CGFloat(progress), cancelEnabled: true)
default:
break
}
}
}
strongSelf.statusNode.transitionToState(state, animated: false, completion: {})
}
strongSelf.isPaused = isPaused
strongSelf.fetchStatus = fetchStatus
if !item.hideControls {
strongSelf.statusButtonNode.isHidden = !initialBuffering && (strongSelf.didPause || !isPaused || value == nil)
strongSelf.statusButtonNode.isHidden = !initialBuffering && (strongSelf.didPause || !isPaused || value == nil) && !fetching
}
if isAnimated || disablePlayerControls {
@ -409,7 +416,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
else if isPaused {
if hasStarted || strongSelf.didPause || buffering {
strongSelf.footerContentNode.content = .playback(paused: true, seekable: seekable)
} else if let fetchStatus = fetchStatus {
} else if let fetchStatus = fetchStatus, !requiresDownload {
strongSelf.footerContentNode.content = .fetch(status: fetchStatus)
}
} else {
@ -760,7 +767,26 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
@objc func statusButtonPressed() {
if let videoNode = self.videoNode {
videoNode.togglePlayPause()
if let fetchStatus = self.fetchStatus, case .Local = fetchStatus {
self.toggleControlsVisibility()
}
if let fetchStatus = self.fetchStatus {
switch fetchStatus {
case .Local:
videoNode.togglePlayPause()
case .Remote:
if self.requiresDownload {
self.fetchControls?.fetch()
} else {
videoNode.togglePlayPause()
}
case .Fetching:
self.fetchControls?.cancel()
}
} else {
videoNode.togglePlayPause()
}
}
}

View File

@ -263,7 +263,7 @@ final class YoutubeEmbedImplementation: WebEmbedImplementation {
playbackStatus = .buffering(initial: true, whilePlaying: false)
}
self.status = MediaPlayerStatus(generationTimestamp: self.status.generationTimestamp, duration: Double(duration), dimensions: self.status.dimensions, timestamp: newTimestamp, baseRate: 1.0, seekId: 0, status: playbackStatus)
self.status = MediaPlayerStatus(generationTimestamp: self.status.generationTimestamp, duration: Double(duration), dimensions: self.status.dimensions, timestamp: newTimestamp, baseRate: 1.0, seekId: self.status.seekId, status: playbackStatus)
updateStatus(self.status)
}
}