add a helper function for checking simple mime type
This commit is contained in:
parent
a817a8caef
commit
e557ac3ede
1 changed files with 3 additions and 1 deletions
|
@ -13,7 +13,7 @@ fun File.isImageSlow() = absolutePath.isImageFast() || getMimeType().startsWith(
|
||||||
fun File.isVideoSlow() = absolutePath.isVideoFast() || getMimeType().startsWith("video")
|
fun File.isVideoSlow() = absolutePath.isVideoFast() || getMimeType().startsWith("video")
|
||||||
fun File.isAudioSlow() = getMimeType().startsWith("audio")
|
fun File.isAudioSlow() = getMimeType().startsWith("audio")
|
||||||
|
|
||||||
fun File.getMimeType(default: String = ""): String {
|
fun File.getMimeType(default: String = getDefaultMimeType()): String {
|
||||||
return try {
|
return try {
|
||||||
val retriever = MediaMetadataRetriever()
|
val retriever = MediaMetadataRetriever()
|
||||||
retriever.setDataSource(path)
|
retriever.setDataSource(path)
|
||||||
|
@ -23,6 +23,8 @@ fun File.getMimeType(default: String = ""): String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun File.getDefaultMimeType() = if (isVideoFast()) "video/*" else "image/*"
|
||||||
|
|
||||||
fun File.getDuration(): String {
|
fun File.getDuration(): String {
|
||||||
val retriever = MediaMetadataRetriever()
|
val retriever = MediaMetadataRetriever()
|
||||||
retriever.setDataSource(path)
|
retriever.setDataSource(path)
|
||||||
|
|
Loading…
Reference in a new issue