浏览代码

gallery video thumbnails generated in background thread + caching

nayooti 5 年之前
父节点
当前提交
00ed8f760b
共有 1 个文件被更改,包括 10 次插入1 次删除
  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)