mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Optional setting for one click pause w/ d-pad center (#160)
Closes #152 Adds a setting to enable one-click-pausing via the D-Pad center button. It is disabled by default. If enabled, when the video is playing, it will be pause and show the controls which is just like pressing the Pause or Play/Pause button. If enable, when the video is paused and controls is not showing, it will resume playback including using the skip back on resume setting.
This commit is contained in:
parent
f12785aaee
commit
b6df72c3c9
5 changed files with 28 additions and 1 deletions
|
|
@ -654,6 +654,18 @@ sealed interface AppPreference<T> {
|
|||
summaryOn = R.string.enabled,
|
||||
summaryOff = R.string.disabled,
|
||||
)
|
||||
|
||||
val OneClickPause =
|
||||
AppSwitchPreference(
|
||||
title = R.string.one_click_pause,
|
||||
defaultValue = false,
|
||||
getter = { it.playbackPreferences.oneClickPause },
|
||||
setter = { prefs, value ->
|
||||
prefs.updatePlaybackPreferences { oneClickPause = value }
|
||||
},
|
||||
summaryOn = R.string.one_click_pause_summary_on,
|
||||
summaryOff = R.string.disabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -732,6 +744,7 @@ val advancedPreferences =
|
|||
title = R.string.playback,
|
||||
preferences =
|
||||
listOf(
|
||||
AppPreference.OneClickPause,
|
||||
AppPreference.SkipIntros,
|
||||
AppPreference.SkipOutros,
|
||||
AppPreference.SkipCommercials,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class PlaybackKeyHandler(
|
|||
private val controllerViewState: ControllerViewState,
|
||||
private val updateSkipIndicator: (Long) -> Unit,
|
||||
private val skipBackOnResume: Duration?,
|
||||
private val oneClickPause: Boolean,
|
||||
private val onInteraction: () -> Unit,
|
||||
) {
|
||||
fun onKeyEvent(it: KeyEvent): Boolean {
|
||||
|
|
@ -33,7 +34,7 @@ class PlaybackKeyHandler(
|
|||
result = false
|
||||
} else if (it.type != KeyEventType.KeyUp) {
|
||||
result = false
|
||||
} else if (isDpad(it)) {
|
||||
} else if (isDirectionalDpad(it) || isEnterKey(it)) {
|
||||
if (!controllerViewState.controlsVisible) {
|
||||
if (skipWithLeftRight && it.key == Key.DirectionLeft) {
|
||||
updateSkipIndicator(-seekBack.inWholeMilliseconds)
|
||||
|
|
@ -41,6 +42,15 @@ class PlaybackKeyHandler(
|
|||
} else if (skipWithLeftRight && it.key == Key.DirectionRight) {
|
||||
player.seekForward(seekForward)
|
||||
updateSkipIndicator(seekForward.inWholeMilliseconds)
|
||||
} else if (oneClickPause && isEnterKey(it)) {
|
||||
Util.handlePlayPauseButtonAction(player)
|
||||
if (!player.isPlaying) {
|
||||
controllerViewState.showControls()
|
||||
} else {
|
||||
skipBackOnResume?.let {
|
||||
player.seekBack(it)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
controllerViewState.showControls()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ fun PlaybackPage(
|
|||
updateSkipIndicator = updateSkipIndicator,
|
||||
skipBackOnResume = preferences.appPreferences.playbackPreferences.skipBackOnResume,
|
||||
onInteraction = viewModel::reportInteraction,
|
||||
oneClickPause = preferences.appPreferences.playbackPreferences.oneClickPause,
|
||||
)
|
||||
|
||||
val showSegment =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue