mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-22 12:48:15 +03:00
feat(player): Add support for editing input.conf (#1165)
This commit is contained in:
parent
63e95d9cbc
commit
418137c74e
4 changed files with 41 additions and 1 deletions
|
@ -20,6 +20,7 @@ object AdvancedPlayerSettingsScreen : SearchableSettings {
|
|||
val playerPreferences = remember { Injekt.get<PlayerPreferences>() }
|
||||
val context = LocalContext.current
|
||||
val mpvConf = playerPreferences.mpvConf()
|
||||
val mpvInput = playerPreferences.mpvInput()
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
return listOf(
|
||||
|
@ -34,6 +35,16 @@ object AdvancedPlayerSettingsScreen : SearchableSettings {
|
|||
),
|
||||
|
||||
),
|
||||
Preference.PreferenceItem.MultiLineEditTextPreference(
|
||||
pref = mpvInput,
|
||||
title = context.getString(R.string.pref_mpv_input),
|
||||
subtitle = mpvInput.asState(scope).value
|
||||
.lines().take(2)
|
||||
.joinToString(
|
||||
separator = "\n",
|
||||
postfix = if (mpvInput.asState(scope).value.lines().size > 2) "\n..." else "",
|
||||
),
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
title = context.getString(R.string.pref_debanding_title),
|
||||
pref = playerPreferences.deband(),
|
||||
|
|
|
@ -407,6 +407,8 @@ class PlayerActivity : BaseActivity() {
|
|||
private fun setupPlayerMPV() {
|
||||
val mpvConfFile = File("${applicationContext.filesDir.path}/mpv.conf")
|
||||
playerPreferences.mpvConf().get().let { mpvConfFile.writeText(it) }
|
||||
val mpvInputFile = File("${applicationContext.filesDir.path}/input.conf")
|
||||
playerPreferences.mpvInput().get().let { mpvInputFile.writeText(it) }
|
||||
|
||||
val logLevel = if (viewModel.networkPreferences.verboseLogging().get()) "info" else "warn"
|
||||
player.initialize(applicationContext.filesDir.path, logLevel)
|
||||
|
@ -422,6 +424,8 @@ class PlayerActivity : BaseActivity() {
|
|||
3 -> MPVLib.setOptionString("vf", "format=yuv420p")
|
||||
}
|
||||
|
||||
MPVLib.setOptionString("input-default-bindings", "yes")
|
||||
|
||||
MPVLib.addLogObserver(playerObserver)
|
||||
player.addObserver(playerObserver)
|
||||
}
|
||||
|
@ -1042,11 +1046,33 @@ class PlayerActivity : BaseActivity() {
|
|||
return true
|
||||
}
|
||||
*/
|
||||
else -> {}
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||
doubleTapSeek(playerPreferences.skipLengthPreference().get())
|
||||
return true
|
||||
}
|
||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||
doubleTapSeek(-playerPreferences.skipLengthPreference().get())
|
||||
return true
|
||||
}
|
||||
KeyEvent.KEYCODE_SPACE -> {
|
||||
doubleTapPlayPause()
|
||||
return true
|
||||
}
|
||||
// add other keycodes as needed
|
||||
else -> {
|
||||
if (player.onKey(event!!)) return true
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
// Removing this causes mpv to repeat the last repeated input
|
||||
// that's not specified in onKeyDown indefinitely for some reason
|
||||
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (player.onKey(event!!)) return true
|
||||
return super.onKeyUp(keyCode, event)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun openTracksSheet(view: View) {
|
||||
val qualityTracks = currentVideoList?.map { Track("", it.quality) }?.toTypedArray()?.takeUnless { it.isEmpty() }
|
||||
|
|
|
@ -31,6 +31,8 @@ class PlayerPreferences(
|
|||
|
||||
fun mpvConf() = preferenceStore.getString("pref_mpv_conf", "")
|
||||
|
||||
fun mpvInput() = preferenceStore.getString("pref_mpv_input", "")
|
||||
|
||||
fun defaultPlayerOrientationType() = preferenceStore.getInt("pref_default_player_orientation_type_key", 10)
|
||||
|
||||
fun adjustOrientationVideoDimensions() = preferenceStore.getBoolean("pref_adjust_orientation_video_dimensions", true)
|
||||
|
|
|
@ -128,6 +128,7 @@
|
|||
<string name="pref_remember_volume">Remember and switch to the last used volume</string>
|
||||
<!-- Needs better English -->
|
||||
<string name="pref_mpv_conf">Edit MPV configuration file for further player settings</string>
|
||||
<string name="pref_mpv_input">Edit MPV input file for keyboard mapping configuration</string>
|
||||
<string name="pref_category_external_player">External player</string>
|
||||
<string name="pref_always_use_external_player">Always use external player</string>
|
||||
<string name="pref_external_player_preference">External player preference</string>
|
||||
|
|
Loading…
Reference in a new issue