mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix video
This commit is contained in:
parent
39f4742cb7
commit
53b4e8fd32
@ -197,10 +197,25 @@ public final class DirectMediaImageCache {
|
||||
continueInBackground: false
|
||||
).start()
|
||||
|
||||
let data = self.account.postbox.mediaBox.resourceData(resource.resource, size: resourceSizeLimit, in: 0 ..< resourceSizeLimit).start(next: { data, _ in
|
||||
let dataValue = data
|
||||
let dataSignal: Signal<Data?, NoError>
|
||||
if resourceSizeLimit < Int(Int32.max) {
|
||||
dataSignal = self.account.postbox.mediaBox.resourceData(resource.resource, size: resourceSizeLimit, in: 0 ..< resourceSizeLimit)
|
||||
|> map { data, _ -> Data? in
|
||||
return data
|
||||
}
|
||||
} else {
|
||||
dataSignal = self.account.postbox.mediaBox.resourceData(resource.resource)
|
||||
|> filter { data in
|
||||
return data.complete
|
||||
}
|
||||
|> take(1)
|
||||
|> map { data -> Data? in
|
||||
return try? Data(contentsOf: URL(fileURLWithPath: data.path))
|
||||
}
|
||||
}
|
||||
|
||||
if let image = UIImage(data: dataValue) {
|
||||
let data = dataSignal.start(next: { data in
|
||||
if let data = data, let image = UIImage(data: data) {
|
||||
let scaledSize = CGSize(width: CGFloat(width), height: CGFloat(width))
|
||||
let scaledContext = DrawingContext(size: scaledSize, scale: 1.0, opaque: true)
|
||||
scaledContext.withFlippedContext { context in
|
||||
@ -243,6 +258,9 @@ public final class DirectMediaImageCache {
|
||||
return (mediaReference.resourceReference(representation.resource), Int(Int32.max))
|
||||
}
|
||||
}
|
||||
if let representation = representations.last {
|
||||
return (mediaReference.resourceReference(representation.resource), Int(Int32.max))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user