Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 105d2a35 authored by Amin Shaikh's avatar Amin Shaikh
Browse files

Check album art for video thumbnails.

If there is no album art set, fall back to the first frame in the video,
as was previously done.

Test: manual
Change-Id: Id091c3c8a8054a87124759eb9be3ba759a115ad4
Fixes: 117161952
parent d4e48c59
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -160,7 +160,15 @@ public class ThumbnailUtils {
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        try {
        try {
            retriever.setDataSource(filePath);
            retriever.setDataSource(filePath);
            // First retrieve album art in metadata if set.
            byte[] embeddedPicture = retriever.getEmbeddedPicture();
            if (embeddedPicture != null && embeddedPicture.length > 0) {
                bitmap = BitmapFactory.decodeByteArray(embeddedPicture, 0, embeddedPicture.length);
            }
            // Fall back to first frame of the video.
            if (bitmap == null) {
                bitmap = retriever.getFrameAtTime(-1);
                bitmap = retriever.getFrameAtTime(-1);
            }
        } catch (IllegalArgumentException ex) {
        } catch (IllegalArgumentException ex) {
            // Assume this is a corrupt video file
            // Assume this is a corrupt video file
        } catch (RuntimeException ex) {
        } catch (RuntimeException ex) {