forked from shadowfacts/Tusker
Use video thumbnails from API when possible
This commit is contained in:
parent
5a26739b78
commit
1ec85ca095
|
@ -184,6 +184,16 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadVideo() {
|
func loadVideo() {
|
||||||
|
if let previewURL = self.attachment.previewURL {
|
||||||
|
attachmentRequest = ImageCache.attachments.get(previewURL, completion: { [weak self] (data, _ )in
|
||||||
|
guard let self = self, let data = data else { return }
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.attachmentRequest = nil
|
||||||
|
self.source = .imageData(previewURL, data)
|
||||||
|
self.displayImage()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
let attachmentURL = self.attachment.url
|
let attachmentURL = self.attachment.url
|
||||||
// todo: use a single dispatch queue
|
// todo: use a single dispatch queue
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
|
@ -194,6 +204,7 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
||||||
self.source = .cgImage(attachmentURL, image)
|
self.source = .cgImage(attachmentURL, image)
|
||||||
self.displayImage()
|
self.displayImage()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let playImageView = UIImageView(image: UIImage(systemName: "play.circle.fill"))
|
let playImageView = UIImageView(image: UIImage(systemName: "play.circle.fill"))
|
||||||
playImageView.translatesAutoresizingMaskIntoConstraints = false
|
playImageView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
Loading…
Reference in New Issue