mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Video avatar fixes
This commit is contained in:
parent
ca2664d6b1
commit
f5b32e80cd
@ -96,7 +96,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
subscriber.putNext({ context in
|
subscriber.putNext({ context in
|
||||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, selectionLimit: Int32(selectionLimit))
|
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||||
return controller!
|
return controller!
|
||||||
})
|
})
|
||||||
subscriber.putCompletion()
|
subscriber.putCompletion()
|
||||||
|
@ -203,10 +203,11 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
|||||||
private let preloadDisposable = MetaDisposable()
|
private let preloadDisposable = MetaDisposable()
|
||||||
private let statusNode: RadialStatusNode
|
private let statusNode: RadialStatusNode
|
||||||
|
|
||||||
private var fetchStatus: MediaResourceStatus?
|
|
||||||
private var playerStatus: MediaPlayerStatus?
|
private var playerStatus: MediaPlayerStatus?
|
||||||
private var isLoading = ValuePromise<Bool>(false)
|
private var isLoading = ValuePromise<Bool>(false)
|
||||||
private var loadingDisposable = MetaDisposable()
|
private var loadingProgress = ValuePromise<Float?>(nil)
|
||||||
|
private var loadingProgressDisposable = MetaDisposable()
|
||||||
|
|
||||||
let isReady = Promise<Bool>()
|
let isReady = Promise<Bool>()
|
||||||
private var didSetReady: Bool = false
|
private var didSetReady: Bool = false
|
||||||
@ -271,19 +272,19 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
|||||||
self.addSubnode(self.imageNode)
|
self.addSubnode(self.imageNode)
|
||||||
self.addSubnode(self.statusNode)
|
self.addSubnode(self.statusNode)
|
||||||
|
|
||||||
self.loadingDisposable.set((self.isLoading.get()
|
self.loadingProgressDisposable.set((combineLatest(self.isLoading.get()
|
||||||
|> mapToSignal { value -> Signal<Bool, NoError> in
|
|> mapToSignal { value -> Signal<Bool, NoError> in
|
||||||
if value {
|
if value {
|
||||||
return .single(value) |> delay(1.0, queue: Queue.mainQueue())
|
return .single(value) |> delay(0.5, queue: Queue.mainQueue())
|
||||||
} else {
|
} else {
|
||||||
return .single(value)
|
return .single(value)
|
||||||
}
|
}
|
||||||
}).start(next: { [weak self] loading in
|
}, self.loadingProgress.get())).start(next: { [weak self] isLoading, progress in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if loading {
|
if isLoading, let progress = progress {
|
||||||
strongSelf.statusNode.transitionToState(.progress(color: .white, lineWidth: nil, value: nil, cancelEnabled: false), completion: {})
|
strongSelf.statusNode.transitionToState(.progress(color: .white, lineWidth: nil, value: CGFloat(progress), cancelEnabled: false), completion: {})
|
||||||
} else {
|
} else {
|
||||||
strongSelf.statusNode.transitionToState(.none, completion: {})
|
strongSelf.statusNode.transitionToState(.none, completion: {})
|
||||||
}
|
}
|
||||||
@ -297,35 +298,26 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func updateStatus() {
|
private func updateStatus() {
|
||||||
guard let videoContent = self.videoContent, let fetchStatus = self.fetchStatus else {
|
guard let videoContent = self.videoContent else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var isBuffering: Bool?
|
var bufferingProgress: Float?
|
||||||
var isPlaying = false
|
|
||||||
if isMediaStreamable(resource: videoContent.fileReference.media.resource) {
|
if isMediaStreamable(resource: videoContent.fileReference.media.resource) {
|
||||||
if let playerStatus = self.playerStatus {
|
if let playerStatus = self.playerStatus {
|
||||||
if case .buffering = playerStatus.status {
|
if case let .buffering(_, _, progress) = playerStatus.status {
|
||||||
isBuffering = true
|
bufferingProgress = progress
|
||||||
|
print(progress)
|
||||||
} else if case .playing = playerStatus.status {
|
} else if case .playing = playerStatus.status {
|
||||||
isPlaying = true
|
bufferingProgress = nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isBuffering = false
|
bufferingProgress = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var progressRequired = false
|
self.loadingProgress.set(bufferingProgress)
|
||||||
if case .Local = fetchStatus {
|
self.isLoading.set(bufferingProgress != nil)
|
||||||
} else if isBuffering ?? false {
|
|
||||||
progressRequired = true
|
|
||||||
} else if case .Fetching = fetchStatus, !isPlaying {
|
|
||||||
progressRequired = true
|
|
||||||
} else if case .Remote = fetchStatus, !isPlaying {
|
|
||||||
progressRequired = true
|
|
||||||
}
|
|
||||||
|
|
||||||
self.isLoading.set(progressRequired)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTransitionFraction(_ fraction: CGFloat, transition: ContainedViewLayoutTransition) {
|
func updateTransitionFraction(_ fraction: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
@ -378,13 +370,12 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
|||||||
let videoStartTimestamp = self.videoStartTimestamp
|
let videoStartTimestamp = self.videoStartTimestamp
|
||||||
self.statusPromise.set(videoNode.status |> map { ($0, videoStartTimestamp) })
|
self.statusPromise.set(videoNode.status |> map { ($0, videoStartTimestamp) })
|
||||||
|
|
||||||
self.statusDisposable.set((combineLatest(self.mediaStatus, self.context.account.postbox.mediaBox.resourceStatus(videoContent.fileReference.media.resource))
|
self.statusDisposable.set((self.mediaStatus
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] mediaStatus, fetchStatus in
|
|> deliverOnMainQueue).start(next: { [weak self] mediaStatus in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
if let mediaStatusAndStartTimestamp = mediaStatus {
|
if let mediaStatusAndStartTimestamp = mediaStatus {
|
||||||
strongSelf.playerStatus = mediaStatusAndStartTimestamp.0
|
strongSelf.playerStatus = mediaStatusAndStartTimestamp.0
|
||||||
}
|
}
|
||||||
strongSelf.fetchStatus = fetchStatus
|
|
||||||
strongSelf.updateStatus()
|
strongSelf.updateStatus()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user