diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt index 8ae760b5eb..f8632aa5d5 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsPlayerScreen.kt @@ -22,16 +22,18 @@ import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.domain.base.BasePreferences import eu.kanade.presentation.more.settings.Preference -import eu.kanade.tachiyomi.ui.player.JUST_PLAYER -import eu.kanade.tachiyomi.ui.player.MPV_PLAYER -import eu.kanade.tachiyomi.ui.player.MPV_REMOTE -import eu.kanade.tachiyomi.ui.player.MX_PLAYER -import eu.kanade.tachiyomi.ui.player.MX_PLAYER_FREE -import eu.kanade.tachiyomi.ui.player.MX_PLAYER_PRO -import eu.kanade.tachiyomi.ui.player.NEXT_PLAYER -import eu.kanade.tachiyomi.ui.player.VLC_PLAYER -import eu.kanade.tachiyomi.ui.player.WEB_VIDEO_CASTER -import eu.kanade.tachiyomi.ui.player.X_PLAYER +import eu.kanade.tachiyomi.ui.player.JustPlayer +import eu.kanade.tachiyomi.ui.player.MpvKt +import eu.kanade.tachiyomi.ui.player.MpvKtPreview +import eu.kanade.tachiyomi.ui.player.MpvPlayer +import eu.kanade.tachiyomi.ui.player.MpvRemote +import eu.kanade.tachiyomi.ui.player.MxPlayer +import eu.kanade.tachiyomi.ui.player.MxPlayerFree +import eu.kanade.tachiyomi.ui.player.MxPlayerPro +import eu.kanade.tachiyomi.ui.player.NextPlayer +import eu.kanade.tachiyomi.ui.player.VlcPlayer +import eu.kanade.tachiyomi.ui.player.WebVideoCaster +import eu.kanade.tachiyomi.ui.player.XPlayer import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences import eu.kanade.tachiyomi.ui.player.viewer.AudioChannels import kotlinx.collections.immutable.persistentListOf @@ -440,14 +442,16 @@ object SettingsPlayerScreen : SearchableSettings { } val externalPlayers = listOf( - MPV_PLAYER, - MX_PLAYER, - MX_PLAYER_FREE, - MX_PLAYER_PRO, - VLC_PLAYER, - MPV_REMOTE, - JUST_PLAYER, - NEXT_PLAYER, - X_PLAYER, - WEB_VIDEO_CASTER, + MpvPlayer, + MxPlayer, + MxPlayerFree, + MxPlayerPro, + VlcPlayer, + MpvKt, + MpvKtPreview, + MpvRemote, + JustPlayer, + NextPlayer, + XPlayer, + WebVideoCaster, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt index db3c68185c..f243263263 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt @@ -170,7 +170,7 @@ class ExternalIntents { */ private fun getIntentForPackage(pkgName: String, context: Context, uri: Uri, video: Video): Intent { return when (pkgName) { - WEB_VIDEO_CASTER -> webVideoCasterIntent(pkgName, context, uri, video) + WebVideoCaster -> webVideoCasterIntent(pkgName, context, uri, video) else -> standardIntentForPackage(pkgName, context, uri, video) } } @@ -178,7 +178,7 @@ class ExternalIntents { private fun webVideoCasterIntent(pkgName: String, context: Context, uri: Uri, video: Video): Intent { return Intent(Intent.ACTION_VIEW).apply { setDataAndType(uri, "video/*") - if (isPackageInstalled(pkgName, context.packageManager)) setPackage(WEB_VIDEO_CASTER) + if (isPackageInstalled(pkgName, context.packageManager)) setPackage(WebVideoCaster) addExtrasAndFlags(true, this) val headers = Bundle() @@ -300,16 +300,17 @@ class ExternalIntents { */ private fun getComponent(packageName: String): ComponentName? { return when (packageName) { - MPV_PLAYER -> ComponentName(packageName, "$packageName.MPVActivity") - MX_PLAYER, MX_PLAYER_FREE, MX_PLAYER_PRO -> ComponentName( + MpvPlayer -> ComponentName(packageName, "$packageName.MPVActivity") + MxPlayer, MxPlayerFree, MxPlayerPro -> ComponentName( packageName, "$packageName.ActivityScreen", ) - VLC_PLAYER -> ComponentName(packageName, "$packageName.gui.video.VideoPlayerActivity") - MPV_REMOTE -> ComponentName(packageName, "$packageName.MainActivity") - JUST_PLAYER -> ComponentName(packageName, "$packageName.PlayerActivity") - NEXT_PLAYER -> ComponentName(packageName, "$packageName.feature.player.PlayerActivity") - X_PLAYER -> ComponentName(packageName, "com.inshot.xplayer.activities.PlayerActivity") + VlcPlayer -> ComponentName(packageName, "$packageName.gui.video.VideoPlayerActivity") + MpvKt, MpvKtPreview -> ComponentName(packageName, "live.mehiz.mpvkt.ui.player.PlayerActivity") + MpvRemote -> ComponentName(packageName, "$packageName.MainActivity") + JustPlayer -> ComponentName(packageName, "$packageName.PlayerActivity") + NextPlayer -> ComponentName(packageName, "$packageName.feature.player.PlayerActivity") + XPlayer -> ComponentName(packageName, "com.inshot.xplayer.activities.PlayerActivity") else -> null } } @@ -559,13 +560,15 @@ class ExternalIntents { } // List of supported external players and their packages -const val MPV_PLAYER = "is.xyz.mpv" -const val MX_PLAYER = "com.mxtech.videoplayer" -const val MX_PLAYER_FREE = "com.mxtech.videoplayer.ad" -const val MX_PLAYER_PRO = "com.mxtech.videoplayer.pro" -const val VLC_PLAYER = "org.videolan.vlc" -const val MPV_REMOTE = "com.husudosu.mpvremote" -const val JUST_PLAYER = "com.brouken.player" -const val NEXT_PLAYER = "dev.anilbeesetti.nextplayer" -const val X_PLAYER = "video.player.videoplayer" -const val WEB_VIDEO_CASTER = "com.instantbits.cast.webvideo" +const val MpvPlayer = "is.xyz.mpv" +const val MxPlayer = "com.mxtech.videoplayer" +const val MxPlayerFree = "com.mxtech.videoplayer.ad" +const val MxPlayerPro = "com.mxtech.videoplayer.pro" +const val VlcPlayer = "org.videolan.vlc" +const val MpvKt = "live.mehiz.mpvkt" +const val MpvKtPreview = "live.mehiz.mpvkt.preview" +const val MpvRemote = "com.husudosu.mpvremote" +const val JustPlayer = "com.brouken.player" +const val NextPlayer = "dev.anilbeesetti.nextplayer" +const val XPlayer = "video.player.videoplayer" +const val WebVideoCaster = "com.instantbits.cast.webvideo" 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 6d99cebe71..715ff6fbc2 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 @@ -112,6 +112,8 @@ import java.io.IOException import java.io.InputStream import java.io.OutputStream import kotlin.math.abs +import kotlin.math.ceil +import kotlin.math.floor import kotlin.math.roundToInt import `is`.xyz.mpv.MPVView.Chapter as VideoChapter @@ -1735,6 +1737,7 @@ class PlayerActivity : BaseActivity() { // at void is.xyz.mpv.MPVLib.event(int) (MPVLib.java:86) @SuppressLint("SourceLockedOrientationActivity") internal suspend fun fileLoaded() { + setMpvMediaTitle() val localLangName = LocaleHelper.getSimpleLocaleDisplayName() clearTracks() player.loadTracks() @@ -1827,6 +1830,24 @@ class PlayerActivity : BaseActivity() { } } + private fun setMpvMediaTitle() { + val anime = viewModel.currentAnime ?: return + val episode = viewModel.currentEpisode ?: return + + val epNumber = episode.episode_number.let { number -> + if (ceil(number) == floor(number)) number.toInt() else number + }.toString().padStart(2, '0') + + val title = stringResource( + MR.strings.mpv_media_title, + anime.title, + epNumber, + episode.name, + ) + + MPVLib.setPropertyString("force-media-title", title) + } + private var aniskipStamps: List = emptyList() private fun updateChapters(stamps: List? = null, duration: Int? = null) { diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 838780e9ed..a1ef5419ef 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -1849,15 +1849,6 @@ TopLevelPropertyNaming:DisplayExtensions.kt$// some tablets have screen width like 711dp = 1600px / 2.25 private const val TABLET_UI_MIN_SCREEN_WIDTH_PORTRAIT_DP = 700 TopLevelPropertyNaming:DisplayExtensions.kt$private const val TABLET_UI_REQUIRED_SCREEN_WIDTH_DP = 720 TopLevelPropertyNaming:ExternalIntents.kt$// List of supported external players and their packages const val MPV_PLAYER = "is.xyz.mpv" - TopLevelPropertyNaming:ExternalIntents.kt$const val JUST_PLAYER = "com.brouken.player" - TopLevelPropertyNaming:ExternalIntents.kt$const val MPV_REMOTE = "com.husudosu.mpvremote" - TopLevelPropertyNaming:ExternalIntents.kt$const val MX_PLAYER = "com.mxtech.videoplayer" - TopLevelPropertyNaming:ExternalIntents.kt$const val MX_PLAYER_FREE = "com.mxtech.videoplayer.ad" - TopLevelPropertyNaming:ExternalIntents.kt$const val MX_PLAYER_PRO = "com.mxtech.videoplayer.pro" - TopLevelPropertyNaming:ExternalIntents.kt$const val NEXT_PLAYER = "dev.anilbeesetti.nextplayer" - TopLevelPropertyNaming:ExternalIntents.kt$const val VLC_PLAYER = "org.videolan.vlc" - TopLevelPropertyNaming:ExternalIntents.kt$const val WEB_VIDEO_CASTER = "com.instantbits.cast.webvideo" - TopLevelPropertyNaming:ExternalIntents.kt$const val X_PLAYER = "video.player.videoplayer" TopLevelPropertyNaming:GLUtil.kt$// Safe minimum default size private const val IMAGE_MAX_BITMAP_DIMENSION = 2048 TopLevelPropertyNaming:GestureHandler.kt$private const val STATE_HORIZONTAL = 1 TopLevelPropertyNaming:GestureHandler.kt$private const val STATE_UP = 0 diff --git a/i18n/src/commonMain/moko-resources/base/strings.xml b/i18n/src/commonMain/moko-resources/base/strings.xml index 10c3f1822a..735644f35f 100644 --- a/i18n/src/commonMain/moko-resources/base/strings.xml +++ b/i18n/src/commonMain/moko-resources/base/strings.xml @@ -915,6 +915,7 @@ Next chapter Previous chapter Skipped opening + %1$s - E%2$s - %3$s Enable precise seeking When enabled, seeking will not focus on keyframes, leading to slower but precise seeking Show content in display cutout