Skip to content

Commit

Permalink
feat: Added settings item to change default player disappear time (#122)
Browse files Browse the repository at this point in the history
* Added settings item to change default player disappear time

* fix: missing ')'

---------

Co-authored-by: AbdallahMehiz <[email protected]>
  • Loading branch information
Anthonyy232 and abdallahmehiz authored Oct 19, 2024
1 parent 1f820af commit 3a752d8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class PlayerPreferences(

val allowGesturesInPanels = preferenceStore.getBoolean("allow_gestures_in_panels")
val showSystemStatusBar = preferenceStore.getBoolean("show_system_status_bar")

val playerTimeToDisappear = preferenceStore.getInt("player_time_to_disappear", 4000)
val allowHeadsetControl = preferenceStore.getBoolean("allow_headset_control", true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ fun PlayerControls(
val gestureSeekAmount by viewModel.gestureSeekAmount.collectAsState()
var isSeeking by remember { mutableStateOf(false) }
var resetControls by remember { mutableStateOf(true) }
val playerTimeToDisappear by playerPreferences.playerTimeToDisappear.collectAsState()
LaunchedEffect(
controlsShown,
paused,
isSeeking,
resetControls,
) {
if (controlsShown && !paused && !isSeeking) {
delay(4_000)
delay(playerTimeToDisappear.toLong())
viewModel.hideControls()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ object PlayerPreferencesScreen : Screen() {
onValueChange = preferences.showSystemStatusBar::set,
title = { Text(stringResource(R.string.pref_player_controls_show_status_bar)) },
)
val playerTimeToDisappear by preferences.playerTimeToDisappear.collectAsState()
ListPreference(
value = playerTimeToDisappear,
onValueChange = preferences.playerTimeToDisappear::set,
values = listOf(500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000),
valueToText = { AnnotatedString("$it ms") },
title = { Text(text = stringResource(R.string.hide_player_control_time)) },
summary = { Text(text = "$playerTimeToDisappear ms") },
enabled = doubleTapToSeek,
)
val allowHeadsetControl by preferences.allowHeadsetControl.collectAsState()
SwitchPreference(
value = allowHeadsetControl,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
<string name="github_repo_url" translatable="false">https://github.com/abdallahmehiz/mpvKt</string>
<string name="control_player_with_media_buttons">Control player with media buttons</string>
<string name="swap_the_volume_and_brightness_slider">Swap volume and brightness slider</string>
<string name="hide_player_control_time">Hide player control time</string>

<plurals name="plural_items">
<item quantity="one">%1$d item</item>
Expand Down

0 comments on commit 3a752d8

Please sign in to comment.