Skip to content

Commit

Permalink
feat(ExtPlayer): Add new players (Just, Next, X)
Browse files Browse the repository at this point in the history
  • Loading branch information
quickdesh committed Jul 25, 2023
1 parent 51c6f7b commit 4ffae67
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import eu.kanade.domain.base.BasePreferences
import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.util.collectAsState
import eu.kanade.tachiyomi.R
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.X_PLAYER
import eu.kanade.tachiyomi.ui.player.settings.PlayerPreferences
import eu.kanade.tachiyomi.util.preference.asState
import tachiyomi.presentation.core.components.WheelTextPicker
Expand Down Expand Up @@ -305,17 +314,8 @@ object SettingsPlayerScreen : SearchableSettings {

val pm = basePreferences.context.packageManager
val installedPackages = pm.getInstalledPackages(0)
val supportedPlayers = installedPackages.filter {
when (it.packageName) {
"is.xyz.mpv" -> true
"com.mxtech.videoplayer" -> true
"com.mxtech.videoplayer.ad" -> true
"com.mxtech.videoplayer.pro" -> true
"org.videolan.vlc" -> true
"com.husudosu.mpvremote" -> true
else -> false
}
}
val supportedPlayers = installedPackages.filter { it.packageName in externalPlayers }

val packageNames = supportedPlayers.map { it.packageName }
val packageNamesReadable = supportedPlayers
.map { pm.getApplicationLabel(it.applicationInfo).toString() }
Expand Down Expand Up @@ -384,3 +384,15 @@ 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,
)
20 changes: 13 additions & 7 deletions app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,12 @@ class ExternalIntents {
private fun getComponent(packageName: String): ComponentName? {
return when (packageName) {
MPV_PLAYER -> ComponentName(packageName, "$packageName.MPVActivity")
MX_PLAYER_FREE, MX_PLAYER_PRO -> ComponentName(packageName, "$packageName.ActivityScreen")
MX_PLAYER, MX_PLAYER_FREE, MX_PLAYER_PRO -> 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")
else -> null
}
}
Expand All @@ -285,7 +288,6 @@ class ExternalIntents {
/**
* Saves the episode's data based on whats returned by the external player.
*
* @param resultCode the code sent to ensure that the returned [intent] is valid.
* @param intent the [Intent] that contains the episode's position and duration.
*/
@OptIn(DelicateCoroutinesApi::class)
Expand Down Expand Up @@ -496,8 +498,12 @@ class ExternalIntents {
}

// List of supported external players and their packages
private const val MPV_PLAYER = "is.xyz.mpv"
private const val MX_PLAYER_FREE = "com.mxtech.videoplayer.ad"
private const val MX_PLAYER_PRO = "com.mxtech.videoplayer.pro"
private const val VLC_PLAYER = "org.videolan.vlc"
private const val MPV_REMOTE = "com.husudosu.mpvremote"
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"

0 comments on commit 4ffae67

Please sign in to comment.