Fix crash reported from rageshake

This commit is contained in:
Benoit Marty 2020-02-26 15:32:52 +01:00
parent 054d7668ef
commit 4ba8a42977
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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 {