display video resolution at videos

This commit is contained in:
tibbi 2016-10-16 17:53:02 +02:00
parent 259ec1a0e7
commit f866f01ddf
2 changed files with 17 additions and 0 deletions

View File

@ -52,6 +52,10 @@ class PropertiesDialog : DialogFragment() {
properties_duration_label.visibility = View.VISIBLE
properties_duration.visibility = View.VISIBLE
properties_duration.text = mItem.getDuration(context)
properties_resolution_label.visibility = View.VISIBLE
properties_resolution.visibility = View.VISIBLE
properties_resolution.text = mItem.getVideoResolution(context)
}
val file = File(mItem.path)

View File

@ -59,6 +59,19 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean,
return getFormattedDuration((timeInMillisec / 1000).toInt())
}
fun getVideoResolution(context: Context): String {
try {
val retriever = MediaMetadataRetriever()
retriever.setDataSource(context, Uri.fromFile(File(path)))
val width = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)
val height = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)
return "$width x $height"
} catch (ignored: Exception) {
}
return ""
}
val imageResolution: String
get () {
val bitmap: Bitmap? = BitmapFactory.decodeFile(path)