From 18b1a0b87cca4ee0e3c45995c5c0eefb9d0dd933 Mon Sep 17 00:00:00 2001 From: jmir1 Date: Thu, 25 Nov 2021 03:13:42 +0100 Subject: [PATCH] fix mime types again --- .../eu/kanade/tachiyomi/ui/anime/AnimeController.kt | 9 ++++++--- .../eu/kanade/tachiyomi/ui/player/PlayerActivity.kt | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/anime/AnimeController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/anime/AnimeController.kt index 8dabfc8c3..bc1b51988 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/anime/AnimeController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/anime/AnimeController.kt @@ -16,7 +16,6 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup -import android.webkit.MimeTypeMap import androidx.annotation.FloatRange import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.view.ActionMode @@ -1107,8 +1106,12 @@ class AnimeController : } private fun getMime(uri: Uri): String { - val extension = MimeTypeMap.getFileExtensionFromUrl(uri.toString()) - return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) ?: MimeTypes.VIDEO_MP4 + return when (uri.path?.substringAfterLast(".")) { + "mp4" -> MimeTypes.VIDEO_MP4 + "mkv" -> MimeTypes.APPLICATION_MATROSKA + "m3u8" -> MimeTypes.APPLICATION_M3U8 + else -> MimeTypes.VIDEO_MP4 + } } override fun onItemClick(view: View?, position: Int): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt index c894f530e..ffefaabf9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt @@ -5,11 +5,11 @@ import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.content.res.Configuration +import android.net.Uri import android.os.Build import android.os.Bundle import android.view.Menu import android.view.View -import android.webkit.MimeTypeMap import android.webkit.WebSettings import android.widget.ImageButton import android.widget.LinearLayout @@ -256,8 +256,12 @@ class PlayerActivity : AppCompatActivity() { } private fun getMime(uri: String): String { - val extension = MimeTypeMap.getFileExtensionFromUrl(uri) - return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) ?: MimeTypes.VIDEO_MP4 + return when (Uri.parse(uri).path?.substringAfterLast(".")) { + "mp4" -> MimeTypes.VIDEO_MP4 + "mkv" -> MimeTypes.APPLICATION_MATROSKA + "m3u8" -> MimeTypes.APPLICATION_M3U8 + else -> MimeTypes.VIDEO_MP4 + } } override fun onCreateOptionsMenu(menu: Menu?): Boolean {