[Android] Add fast play speed SeekBar and migration
Kerry Shen
git at videolan.org
Mon Jun 30 09:45:09 UTC 2025
vlc-android | branch: master | Kerry Shen <kefishen at gmail.com> | Sat Jun 28 14:21:51 2025 +0800| [4fb712e3760315765fe271fd31d9420a696ab371] | committer: Kerry Shen
Add fast play speed SeekBar and migration
> https://code.videolan.org/videolan/vlc-android/commit/4fb712e3760315765fe271fd31d9420a696ab371
---
.../resources/src/main/res/values/arrays.xml | 16 ---------------
.../resources/src/main/res/values/strings.xml | 1 +
.../src/main/java/org/videolan/tools/Settings.kt | 2 +-
.../res/xml/preferences_video_controls.xml | 12 ++++++-----
.../gui/preferences/PreferencesVideoControls.kt | 9 +++++++-
.../src/org/videolan/vlc/util/VersionMigration.kt | 24 +++++++++++++++++++++-
6 files changed, 40 insertions(+), 24 deletions(-)
diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml
index 9877c884fe..b950e24ea4 100644
--- a/application/resources/src/main/res/values/arrays.xml
+++ b/application/resources/src/main/res/values/arrays.xml
@@ -642,22 +642,6 @@
<item>2</item>
</string-array>
- <string-array name="fastplay_speed_entries">
- <item>1.25x</item>
- <item>1.5x</item>
- <item>2x</item>
- <item>4x</item>
- <item>8x</item>
- </string-array>
-
- <string-array name="fastplay_speed_values">
- <item>1.25</item>
- <item>1.5</item>
- <item>2</item>
- <item>4</item>
- <item>8</item>
- </string-array>
-
<string-array name="widget_themes_entries" translatable="false">
<item>@string/material_you</item>
<item>@string/palette</item>
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 315aa1d285..d7b5ab4d66 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -420,6 +420,7 @@
<string name="enable_tap_and_hold_fastplay_title">Enable Fastplay</string>
<string name="enable_tap_and_hold_fastplay_summary">Tap and hold to increase the playback speed</string>
<string name="fastplay_speed_title">Fastplay speed</string>
+ <string name="fastplay_speed_summary">%sx</string>
<string name="fastplay_title">Playing at %sx</string>
<string name="fastplay_subtitle">Release to stop</string>
<string name="show_bookmark_buttons">Show bookmark buttons</string>
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index aaa2b71763..728dbc8776 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -62,7 +62,7 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicat
incognitoMode = prefs.getBoolean(KEY_INCOGNITO, false)
safeMode = prefs.getBoolean(KEY_SAFE_MODE, false) && prefs.getString(KEY_SAFE_MODE_PIN, "")?.isNotBlank() == true
remoteAccessEnabled.postValue(prefs.getBoolean(KEY_ENABLE_REMOTE_ACCESS, false))
- fastplaySpeed = prefs.getString(FASTPLAY_SPEED, "2")?.toFloat() ?: 2f
+ fastplaySpeed = prefs.getInt(FASTPLAY_SPEED, 8) * 0.25f
return prefs
}
diff --git a/application/vlc-android/res/xml/preferences_video_controls.xml b/application/vlc-android/res/xml/preferences_video_controls.xml
index c76a3aac1e..b6407119b2 100644
--- a/application/vlc-android/res/xml/preferences_video_controls.xml
+++ b/application/vlc-android/res/xml/preferences_video_controls.xml
@@ -105,16 +105,18 @@
android:title="@string/enable_tap_and_hold_fastplay_title"
app:iconSpaceReserved="false"
app:singleLineTitle="false" />
- <ListPreference
- android:defaultValue="2"
+ <SeekBarPreference
+ android:defaultValue="8"
android:dependency="enable_fastplay"
- android:entries="@array/fastplay_speed_entries"
- android:entryValues="@array/fastplay_speed_values"
android:key="fastplay_speed"
+ android:max="32"
android:summary="%s"
android:title="@string/fastplay_speed_title"
app:iconSpaceReserved="false"
- app:singleLineTitle="false" />
+ app:min="5"
+ app:seekBarIncrement="1"
+ app:singleLineTitle="false"
+ app:updatesContinuously="true" />
</PreferenceCategory>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt
index 98caff20ae..04f4b6bad6 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt
@@ -49,6 +49,7 @@ import org.videolan.tools.SCREENSHOT_MODE
import org.videolan.tools.Settings
import org.videolan.tools.VIDEO_HUD_TIMEOUT
import org.videolan.tools.coerceInOrDefault
+import org.videolan.tools.readableString
import org.videolan.vlc.R
import org.videolan.vlc.gui.video.VideoPlayerActivity
@@ -78,6 +79,7 @@ class PreferencesVideoControls : BasePreferenceFragment(), SharedPreferences.OnS
findPreference<Preference>(LOCK_USE_SENSOR)?.isVisible = !AndroidDevices.isAndroidTv
updateHudTimeoutSummary()
+ updateFastplaySpeedSummary()
val audiomanager = requireActivity().getSystemService<AudioManager>()!!
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || audiomanager.isVolumeFixed) {
audioBoostPref?.isChecked = false
@@ -97,6 +99,10 @@ class PreferencesVideoControls : BasePreferenceFragment(), SharedPreferences.OnS
}
}
+ private fun updateFastplaySpeedSummary() {
+ findPreference<Preference>(FASTPLAY_SPEED)?.summary = getString(R.string.fastplay_speed_summary, Settings.fastplaySpeed.readableString())
+ }
+
override fun onStart() {
super.onStart()
preferenceScreen.sharedPreferences!!.registerOnSharedPreferenceChangeListener(this)
@@ -126,7 +132,8 @@ class PreferencesVideoControls : BasePreferenceFragment(), SharedPreferences.OnS
Settings.videoDoubleTapJumpDelay = sharedPreferences.getInt(KEY_VIDEO_DOUBLE_TAP_JUMP_DELAY, 20)
}
FASTPLAY_SPEED -> {
- Settings.fastplaySpeed = sharedPreferences.getString(FASTPLAY_SPEED, "2")?.toFloat() ?: 2f
+ Settings.fastplaySpeed = sharedPreferences.getInt(FASTPLAY_SPEED, 8) * 0.25f
+ updateFastplaySpeedSummary()
}
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
index 90c816746a..218636b67b 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
@@ -59,7 +59,7 @@ import org.videolan.vlc.isVLC4
import java.io.File
import java.io.IOException
-private const val CURRENT_VERSION = 15
+private const val CURRENT_VERSION = 16
object VersionMigration {
@@ -126,6 +126,10 @@ object VersionMigration {
migrateToVersion15(settings)
}
+ if (lastVersion < 16) {
+ migrateToVersion16(settings)
+ }
+
//Major version upgrade
if (lastMajorVersion == 3 && currentMajorVersion == 4) {
migrateToVlc4(settings)
@@ -392,6 +396,24 @@ object VersionMigration {
}
}
+ /**
+ * Migrate the fast play speed setting
+ *
+ */
+ private fun migrateToVersion16(settings: SharedPreferences) {
+ Log.i(this::class.java.simpleName, "Migrate to version 16: Migrate the fast play speed setting")
+ if (settings.contains("fastplay_speed")) {
+ settings.edit(true) {
+ putInt("fastplay_speed", settings.getString("fastplay_speed", "2")
+ ?.toFloat()
+ ?.div(0.25f)
+ ?.toInt()
+ ?.coerceInOrDefault(5, 32, 8)
+ ?: 8)
+ }
+ }
+ }
+
/**
* Migration to vlc 4
* ⚠️⚠️⚠️ This should not be destructive! Any first install will run this.
More information about the Android
mailing list