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