diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ThumbnailExtractor.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ThumbnailExtractor.kt index f8935e9283..083cac0278 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ThumbnailExtractor.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/ThumbnailExtractor.kt @@ -46,7 +46,7 @@ internal object ThumbnailExtractor { } private fun extractVideoThumbnail(attachment: ContentAttachmentData): ThumbnailData? { - val thumbnail = ThumbnailUtils.createVideoThumbnail(attachment.path, MediaStore.Video.Thumbnails.MINI_KIND) + val thumbnail = ThumbnailUtils.createVideoThumbnail(attachment.path, MediaStore.Video.Thumbnails.MINI_KIND) ?: return null val outputStream = ByteArrayOutputStream() thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, outputStream) val thumbnailWidth = thumbnail.width diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt index f77f4b7f3a..51de36291d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt @@ -16,6 +16,7 @@ package im.vector.matrix.android.internal.session.room.send +import android.graphics.Bitmap import android.media.MediaMetadataRetriever import androidx.exifinterface.media.ExifInterface import im.vector.matrix.android.R @@ -275,9 +276,9 @@ internal class LocalEchoEventFactory @Inject constructor( mediaDataRetriever.setDataSource(attachment.path) // Use frame to calculate height and width as we are sure to get the right ones - val firstFrame = mediaDataRetriever.frameAtTime - val height = firstFrame.height - val width = firstFrame.width + val firstFrame: Bitmap? = mediaDataRetriever.frameAtTime + val height = firstFrame?.height ?: 0 + val width = firstFrame?.width ?: 0 mediaDataRetriever.release() val thumbnailInfo = ThumbnailExtractor.extractThumbnail(attachment)?.let {