[Android] Mitigate black video thumbnails provided by Android

Nicolas Pomepuy git at videolan.org
Thu Apr 9 09:29:46 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Mar 30 11:15:28 2020 +0200| [0520ca6ba5baaef3db5e5bf697ea00ba8eb0c7d1] | committer: Nicolas Pomepuy

Mitigate black video thumbnails provided by Android

> https://code.videolan.org/videolan/vlc-android/commit/0520ca6ba5baaef3db5e5bf697ea00ba8eb0c7d1
---

 .../vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt b/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
index 28f4666f7..cb6faa9da 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/ThumbnailsProvider.kt
@@ -84,9 +84,15 @@ object ThumbnailsProvider {
         if (cacheBM != null) return cacheBM
         if (hasCache && File(thumbPath).exists()) return readCoverBitmap(thumbPath, width)
         if (media.isThumbnailGenerated) return null
-        val bitmap = synchronized(lock) {
+        var bitmap = synchronized(lock) {
             ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.MINI_KIND)
         }
+        if (bitmap != null) {
+            val emptyBitmap = Bitmap.createBitmap(bitmap.width, bitmap.height, bitmap.config)
+            if (bitmap.sameAs(emptyBitmap)) { // myBitmap is empty/blank3
+                bitmap = null
+            }
+        }
         if (bitmap != null) {
             BitmapCache.addBitmapToMemCache(thumbPath, bitmap)
             if (hasCache) {



More information about the Android mailing list