Browse Source

gallery video thumbnails generated in background thread + caching

nayooti 5 years ago
parent
commit
00ed8f760b
1 changed files with 10 additions and 1 deletions
  1. 10 1
      deltachat-ios/View/Cell/GalleryCell.swift

+ 10 - 1
deltachat-ios/View/Cell/GalleryCell.swift

@@ -53,7 +53,16 @@ class GalleryCell: UICollectionViewCell {
             imageView.image = msg.image
             playButtonView.isHidden = true
         case .video:
-            imageView.image = DcUtils.generateThumbnailFromVideo(url: fileUrl)
+            let key = fileUrl.absoluteString
+            if let image = ThumbnailCache.shared.restoreImage(key: key) {
+                imageView.image = image
+            } else {
+                imageView.loadVideoThumbnail(from: fileUrl, placeholderImage: nil) { thumbnail in
+                    if let image = thumbnail {
+                        ThumbnailCache.shared.storeImage(image: image, key: key)
+                    }
+                }
+            }
             playButtonView.isHidden = false
         case .gif:
             imageView.sd_setImage(with: fileUrl, placeholderImage: nil)