[Android] Add a "force shuffling" audio control setting

Nicolas Pomepuy git at videolan.org
Wed Sep 21 13:28:48 UTC 2022


vlc-android | branch: 3.5.x | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Sep 21 10:03:26 2022 +0200| [215ef9bc96af4ed8db3e8c1d2c0eb6d8735c8d00] | committer: Duncan McNamara

Add a "force shuffling" audio control setting

Fixe's #2675

> https://code.videolan.org/videolan/vlc-android/commit/215ef9bc96af4ed8db3e8c1d2c0eb6d8735c8d00
---

 application/resources/src/main/res/values/strings.xml              | 2 ++
 application/tools/src/main/java/org/videolan/tools/Settings.kt     | 1 +
 application/vlc-android/res/xml/preferences_audio_controls.xml     | 7 +++++++
 .../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt      | 2 ++
 4 files changed, 12 insertions(+)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index ef61758cd..182b3ae6f 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -483,6 +483,8 @@
     <string name="resume_playback_summary">Stay in pause otherwise</string>
     <string name="blurred_cover_background_title">Blurred cover background</string>
     <string name="blurred_cover_background_summary">Blurred cover in audio player background</string>
+    <string name="force_shuffle_title">Force shuffle</string>
+    <string name="force_shuffle_summary">Force shuffling when launching a playback</string>
     <string name="network_caching_popup">This value must be between 0 and 60000 ms</string>
     <string name="quit">Quit and restart application</string>
     <string name="restart_message">Changes will take effect once application has restarted.\n\nRestart now?</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 e6ecc9a68..2dcbe517e 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -88,6 +88,7 @@ const val KEY_VIDEO_LONG_JUMP_DELAY = "video_long_jump_delay"
 const val KEY_VIDEO_DOUBLE_TAP_JUMP_DELAY = "video_double_tap_jump_delay"
 const val KEY_AUDIO_JUMP_DELAY = "audio_jump_delay"
 const val KEY_AUDIO_LONG_JUMP_DELAY = "audio_long_jump_delay"
+const val KEY_AUDIO_FORCE_SHUFFLE = "audio_force_shuffle"
 
 
 // AudioPlayer
diff --git a/application/vlc-android/res/xml/preferences_audio_controls.xml b/application/vlc-android/res/xml/preferences_audio_controls.xml
index 1285e31b7..83602c22d 100644
--- a/application/vlc-android/res/xml/preferences_audio_controls.xml
+++ b/application/vlc-android/res/xml/preferences_audio_controls.xml
@@ -24,6 +24,13 @@
             android:summary="%ss"
             android:defaultValue="20"/>
 
+    <CheckBoxPreference
+            app:singleLineTitle="false"
+            android:defaultValue="false"
+            android:key="audio_force_shuffle"
+            android:summary="@string/force_shuffle_summary"
+            android:title="@string/force_shuffle_title"/>
+
 
 
 </androidx.preference.PreferenceScreen>
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 1f6dac6ed..66006ece6 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -191,6 +191,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             service.onMediaListChanged()
             service.showNotification()
         }
+        if (settings.getBoolean(KEY_AUDIO_FORCE_SHUFFLE, false) && !shuffling && canShuffle()) shuffle()
     }
 
     @Volatile
@@ -863,6 +864,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         }
         mediaList.addEventListener(this)
         addUpdateActor.trySend(Unit)
+        if (settings.getBoolean(KEY_AUDIO_FORCE_SHUFFLE, false) && !shuffling && canShuffle()) shuffle()
     }
 
     /**



More information about the Android mailing list