feat(player): Add a setting to adjust player seek duration

Create a seekOffset dropdown setting defaulting to 10 seconds.
Update the fastForwardTick method  of the GestureControlView to take the
seekOffset setting into account and update the view accordingly.
This commit is contained in:
Alexandre Picavet 2025-01-09 17:44:11 +01:00
commit daf1d42a0f
No known key found for this signature in database
GPG key ID: 459F2C955330B4EC
4 changed files with 40 additions and 6 deletions

View file

@ -486,6 +486,22 @@ class Settings : FragmentedStorageFileJson() {
@FormField(R.string.delete_watchlist_on_finish, FieldForm.TOGGLE, R.string.delete_watchlist_on_finish_description, 22) @FormField(R.string.delete_watchlist_on_finish, FieldForm.TOGGLE, R.string.delete_watchlist_on_finish_description, 22)
var deleteFromWatchLaterAuto: Boolean = true; var deleteFromWatchLaterAuto: Boolean = true;
@FormField(R.string.seek_offset, FieldForm.DROPDOWN, R.string.seek_offset_description, 23)
@DropdownFieldOptionsId(R.array.seek_offset_duration)
var seekOffset: Int = 2;
fun getSeekOffset(): Long {
return when(seekOffset) {
0 -> 3_000L;
1 -> 5_000L;
2 -> 10_000L;
3 -> 20_000L;
4 -> 30_000L;
5 -> 60_000L;
else -> 10_000L;
}
}
} }
@FormField(R.string.comments, "group", R.string.comments_description, 6) @FormField(R.string.comments, "group", R.string.comments_description, 6)

View file

@ -628,12 +628,12 @@ class GestureControlView : LinearLayout {
private fun fastForwardTick() { private fun fastForwardTick() {
_fastForwardCounter++; _fastForwardCounter++;
val seekOffset: Long = 10000; val seekOffset: Long = Settings.instance.playback.getSeekOffset();
if (_rewinding) { if (_rewinding) {
_textRewind.text = "${_fastForwardCounter * 10} " + context.getString(R.string.seconds); _textRewind.text = "${_fastForwardCounter * seekOffset / 1_000} " + context.getString(R.string.seconds);
onSeek.emit(-seekOffset); onSeek.emit(-seekOffset);
} else { } else {
_textFastForward.text = "${_fastForwardCounter * 10} " + context.getString(R.string.seconds); _textFastForward.text = "${_fastForwardCounter * seekOffset / 1_000} " + context.getString(R.string.seconds);
onSeek.emit(seekOffset); onSeek.emit(seekOffset);
} }
} }

View file

@ -688,6 +688,14 @@
<item>Continuer la lecture</item> <item>Continuer la lecture</item>
<item>Superposition du lecteur</item> <item>Superposition du lecteur</item>
</string-array> </string-array>
<string-array name="seek_offset_duration">
<item>3 secondes</item>
<item>5 secondes</item>
<item>10 secondes</item>
<item>20 secondes</item>
<item>30 secondes</item>
<item>60 secondes</item>
</string-array>
<string-array name="resume_after_preview"> <string-array name="resume_after_preview">
<item>Reprendre depuis le début</item> <item>Reprendre depuis le début</item>
<item>Reprendre après 10s</item> <item>Reprendre après 10s</item>

View file

@ -403,6 +403,8 @@
<string name="allow_full_screen_portrait">Allow full-screen portrait when watching horizontal videos</string> <string name="allow_full_screen_portrait">Allow full-screen portrait when watching horizontal videos</string>
<string name="delete_watchlist_on_finish">Delete from WatchLater when watched</string> <string name="delete_watchlist_on_finish">Delete from WatchLater when watched</string>
<string name="delete_watchlist_on_finish_description">After you leave a video that you mostly watched, it will be removed from watch later.</string> <string name="delete_watchlist_on_finish_description">After you leave a video that you mostly watched, it will be removed from watch later.</string>
<string name="seek_offset">Seek duration</string>
<string name="seek_offset_description">Fast-Forward / Fast-Rewind duration</string>
<string name="background_switch_audio">Switch to Audio in Background</string> <string name="background_switch_audio">Switch to Audio in Background</string>
<string name="background_switch_audio_description">Optimize bandwidth usage by switching to audio-only stream in background if available, may cause stutter</string> <string name="background_switch_audio_description">Optimize bandwidth usage by switching to audio-only stream in background if available, may cause stutter</string>
<string name="subscription_group_menu">Groups</string> <string name="subscription_group_menu">Groups</string>
@ -1026,6 +1028,14 @@
<item>Within 30 seconds of loss</item> <item>Within 30 seconds of loss</item>
<item>Always</item> <item>Always</item>
</string-array> </string-array>
<string-array name="seek_offset_duration">
<item>3 seconds</item>
<item>5 seconds</item>
<item>10 seconds</item>
<item>20 seconds</item>
<item>30 seconds</item>
<item>60 seconds</item>
</string-array>
<string-array name="rotation_zone"> <string-array name="rotation_zone">
<item>15</item> <item>15</item>
<item>30</item> <item>30</item>