[Android] Reset playback rate when persistence is enabled

Robert Stone git at videolan.org
Mon Dec 18 08:24:47 UTC 2023


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Sun Dec 17 11:40:46 2023 -0800| [382396af71cd003cc4d303348684749e78fe66fd] | committer: Robert Stone

Reset playback rate when persistence is enabled

> https://code.videolan.org/videolan/vlc-android/commit/382396af71cd003cc4d303348684749e78fe66fd
---

 .../java/org/videolan/television/ui/preferences/PreferencesAudio.kt  | 4 ++++
 .../java/org/videolan/television/ui/preferences/PreferencesVideo.kt  | 5 +++++
 .../src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt         | 4 ++++
 .../src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt         | 4 ++++
 4 files changed, 17 insertions(+)

diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
index 6b1000c49d..cf9e4427d8 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
@@ -41,9 +41,12 @@ import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.libvlc.util.HWDecoderUtil
 import org.videolan.resources.VLCInstance
 import org.videolan.tools.AUDIO_DUCKING
+import org.videolan.tools.KEY_PLAYBACK_RATE
+import org.videolan.tools.KEY_PLAYBACK_SPEED_PERSIST
 import org.videolan.tools.LocaleUtils
 import org.videolan.tools.RESUME_PLAYBACK
 import org.videolan.tools.Settings
+import org.videolan.tools.putSingle
 import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.helpers.restartMediaPlayer
@@ -162,6 +165,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
                     } else launch { restartLibVLC() }
                 }
             }
+            KEY_PLAYBACK_SPEED_PERSIST -> sharedPreferences.putSingle(KEY_PLAYBACK_RATE, 1.0f)
         }
     }
 
diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt
index d07b86a051..539f8e0cb1 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt
@@ -31,9 +31,12 @@ import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.MainScope
 import kotlinx.coroutines.launch
 import org.videolan.resources.VLCInstance
+import org.videolan.tools.KEY_PLAYBACK_RATE_VIDEO
+import org.videolan.tools.KEY_PLAYBACK_SPEED_PERSIST_VIDEO
 import org.videolan.tools.LOCK_USE_SENSOR
 import org.videolan.tools.POPUP_FORCE_LEGACY
 import org.videolan.tools.SAVE_BRIGHTNESS
+import org.videolan.tools.putSingle
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.helpers.restartMediaPlayer
 
@@ -67,6 +70,7 @@ class PreferencesVideo : BasePreferenceFragment(), SharedPreferences.OnSharedPre
     }
 
     override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
+        if (sharedPreferences == null || key == null) return
         when (key) {
             "preferred_resolution" -> {
                 launch {
@@ -74,6 +78,7 @@ class PreferencesVideo : BasePreferenceFragment(), SharedPreferences.OnSharedPre
                     restartMediaPlayer()
                 }
             }
+            KEY_PLAYBACK_SPEED_PERSIST_VIDEO -> sharedPreferences.putSingle(KEY_PLAYBACK_RATE_VIDEO, 1.0f)
         }
     }
 }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
index 5abf1fa9dd..9c29387bf8 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
@@ -43,9 +43,12 @@ import org.videolan.libvlc.util.HWDecoderUtil
 import org.videolan.resources.AndroidDevices
 import org.videolan.resources.VLCInstance
 import org.videolan.tools.AUDIO_DUCKING
+import org.videolan.tools.KEY_PLAYBACK_RATE
+import org.videolan.tools.KEY_PLAYBACK_SPEED_PERSIST
 import org.videolan.tools.LocaleUtils
 import org.videolan.tools.RESUME_PLAYBACK
 import org.videolan.tools.Settings
+import org.videolan.tools.putSingle
 import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.browser.EXTRA_MRL
@@ -186,6 +189,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
                     } else lifecycleScope.launch { restartLibVLC() }
                 }
             }
+            KEY_PLAYBACK_SPEED_PERSIST -> sharedPreferences.putSingle(KEY_PLAYBACK_RATE, 1.0f)
         }
     }
 
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt
index 7f8890d0f9..09cbfa31f7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt
@@ -29,7 +29,10 @@ import androidx.preference.Preference
 import kotlinx.coroutines.launch
 import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.resources.VLCInstance
+import org.videolan.tools.KEY_PLAYBACK_RATE_VIDEO
+import org.videolan.tools.KEY_PLAYBACK_SPEED_PERSIST_VIDEO
 import org.videolan.tools.POPUP_FORCE_LEGACY
+import org.videolan.tools.putSingle
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.helpers.restartMediaPlayer
 import org.videolan.vlc.util.Permissions
@@ -69,6 +72,7 @@ class PreferencesVideo : BasePreferenceFragment(), SharedPreferences.OnSharedPre
                 if (sharedPreferences.getBoolean(key, false) && !Permissions.canDrawOverlays(requireActivity())) Permissions.checkDrawOverlaysPermission(requireActivity())
                 if (!sharedPreferences.getBoolean(key, false) && !Permissions.isPiPAllowed(requireActivity())) Permissions.checkPiPPermission(requireActivity())
             }
+            KEY_PLAYBACK_SPEED_PERSIST_VIDEO -> sharedPreferences.putSingle(KEY_PLAYBACK_RATE_VIDEO, 1.0f)
         }
     }
 }



More information about the Android mailing list