|
|
@ -113,7 +113,15 @@ fun getImageThumbnail(contentResolver: ContentResolver, uri: Uri, @Px thumbnailS |
|
|
|
|
|
|
|
|
|
|
|
fun getVideoThumbnail(context: Context, uri: Uri, @Px thumbnailSize: Int): Bitmap? { |
|
|
|
fun getVideoThumbnail(context: Context, uri: Uri, @Px thumbnailSize: Int): Bitmap? { |
|
|
|
val retriever = MediaMetadataRetriever() |
|
|
|
val retriever = MediaMetadataRetriever() |
|
|
|
|
|
|
|
try { |
|
|
|
retriever.setDataSource(context, uri) |
|
|
|
retriever.setDataSource(context, uri) |
|
|
|
|
|
|
|
} catch (e: IllegalArgumentException) { |
|
|
|
|
|
|
|
Log.w(TAG, e) |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} catch (e: SecurityException) { |
|
|
|
|
|
|
|
Log.w(TAG, e) |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
val source = retriever.frameAtTime ?: return null |
|
|
|
val source = retriever.frameAtTime ?: return null |
|
|
|
return ThumbnailUtils.extractThumbnail(source, thumbnailSize, thumbnailSize, ThumbnailUtils.OPTIONS_RECYCLE_INPUT) |
|
|
|
return ThumbnailUtils.extractThumbnail(source, thumbnailSize, thumbnailSize, ThumbnailUtils.OPTIONS_RECYCLE_INPUT) |
|
|
|
} |
|
|
|
} |
|
|
|