mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Add setting to automatically switch between ExoPlayer & MPV (#736)
## Description The MPV backend is no longer considered experimental. This PR adds a setting for player backend "Prefer MPV" which uses MPV for all playback unless the video is HDR which then uses ExoPlayer. Switching occurs per video. So if there's a playlist with both SDR & HDR, the player will switch back and forth as needed. ### Related issues Closes #253 Related to #235
This commit is contained in:
parent
16ac02a3fd
commit
0639a7a1da
13 changed files with 892 additions and 648 deletions
|
|
@ -746,16 +746,29 @@ sealed interface AppPreference<Pref, T> {
|
|||
val PlayerBackendPref =
|
||||
AppChoicePreference<AppPreferences, PlayerBackend>(
|
||||
title = R.string.player_backend,
|
||||
defaultValue = PlayerBackend.EXO_PLAYER,
|
||||
defaultValue = PlayerBackend.PREFER_MPV,
|
||||
getter = { it.playbackPreferences.playerBackend },
|
||||
setter = { prefs, value ->
|
||||
prefs.updatePlaybackPreferences { playerBackend = value }
|
||||
},
|
||||
displayValues = R.array.player_backend_options,
|
||||
subtitles = R.array.player_backend_options_subtitles,
|
||||
indexToValue = { PlayerBackend.forNumber(it) },
|
||||
valueToIndex = { it.number },
|
||||
)
|
||||
|
||||
val ExoPlayerSettings =
|
||||
AppDestinationPreference<AppPreferences>(
|
||||
title = R.string.exoplayer_options,
|
||||
destination = Destination.Settings(PreferenceScreenOption.EXO_PLAYER),
|
||||
)
|
||||
|
||||
val MpvSettings =
|
||||
AppDestinationPreference<AppPreferences>(
|
||||
title = R.string.mpv_options,
|
||||
destination = Destination.Settings(PreferenceScreenOption.MPV),
|
||||
)
|
||||
|
||||
val MpvHardwareDecoding =
|
||||
AppSwitchPreference<AppPreferences>(
|
||||
title = R.string.mpv_hardware_decoding,
|
||||
|
|
@ -958,6 +971,40 @@ val basicPreferences =
|
|||
|
||||
val uiPreferences = listOf<PreferenceGroup>()
|
||||
|
||||
private val ExoPlayerSettings =
|
||||
listOf(
|
||||
AppPreference.FfmpegPreference,
|
||||
AppPreference.DownMixStereo,
|
||||
AppPreference.Ac3Supported,
|
||||
AppPreference.DirectPlayAss,
|
||||
AppPreference.DirectPlayPgs,
|
||||
AppPreference.DirectPlayDoviProfile7,
|
||||
AppPreference.DecodeAv1,
|
||||
)
|
||||
|
||||
val ExoPlayerPreferences =
|
||||
listOf(
|
||||
PreferenceGroup(
|
||||
title = R.string.exoplayer_options,
|
||||
preferences = ExoPlayerSettings,
|
||||
),
|
||||
)
|
||||
|
||||
private val MpvSettings =
|
||||
listOf(
|
||||
AppPreference.MpvHardwareDecoding,
|
||||
AppPreference.MpvGpuNext,
|
||||
AppPreference.MpvConfFile,
|
||||
)
|
||||
|
||||
val MpvPreferences =
|
||||
listOf(
|
||||
PreferenceGroup(
|
||||
title = R.string.mpv_options,
|
||||
preferences = MpvSettings,
|
||||
),
|
||||
)
|
||||
|
||||
val advancedPreferences =
|
||||
buildList {
|
||||
add(
|
||||
|
|
@ -1008,22 +1055,17 @@ val advancedPreferences =
|
|||
listOf(
|
||||
ConditionalPreferences(
|
||||
{ it.playbackPreferences.playerBackend == PlayerBackend.EXO_PLAYER },
|
||||
listOf(
|
||||
AppPreference.FfmpegPreference,
|
||||
AppPreference.DownMixStereo,
|
||||
AppPreference.Ac3Supported,
|
||||
AppPreference.DirectPlayAss,
|
||||
AppPreference.DirectPlayPgs,
|
||||
AppPreference.DirectPlayDoviProfile7,
|
||||
AppPreference.DecodeAv1,
|
||||
),
|
||||
ExoPlayerSettings,
|
||||
),
|
||||
ConditionalPreferences(
|
||||
{ it.playbackPreferences.playerBackend == PlayerBackend.MPV },
|
||||
MpvSettings,
|
||||
),
|
||||
ConditionalPreferences(
|
||||
{ it.playbackPreferences.playerBackend == PlayerBackend.PREFER_MPV },
|
||||
listOf(
|
||||
AppPreference.MpvHardwareDecoding,
|
||||
AppPreference.MpvGpuNext,
|
||||
AppPreference.MpvConfFile,
|
||||
AppPreference.ExoPlayerSettings,
|
||||
AppPreference.MpvSettings,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -1108,6 +1150,7 @@ data class AppChoicePreference<Pref, T>(
|
|||
override val getter: (prefs: Pref) -> T,
|
||||
override val setter: (prefs: Pref, value: T) -> Pref,
|
||||
@param:StringRes val summary: Int? = null,
|
||||
@param:ArrayRes val subtitles: Int? = null,
|
||||
) : AppPreference<Pref, T>
|
||||
|
||||
data class AppMultiChoicePreference<Pref, T>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue