[Android] Settings: add audio playlist mode

Duncan McNamara git at videolan.org
Tue Aug 30 06:07:33 UTC 2022


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu Aug 18 17:13:54 2022 +0200| [680cb8593475b8a5cf4c073dbe2961a901636eb1] | committer: Nicolas Pomepuy

Settings: add audio playlist mode

The previous setting video playlist mode, to play all files in directory
when clicking on one also affected audio in the file browser, this
splits the setting in two to be more explicit

> https://code.videolan.org/videolan/vlc-android/commit/680cb8593475b8a5cf4c073dbe2961a901636eb1
---

 application/resources/src/main/res/values/strings.xml   |  2 ++
 .../tools/src/main/java/org/videolan/tools/Settings.kt  |  1 +
 application/vlc-android/res/xml/preferences_ui.xml      |  6 ++++++
 .../org/videolan/vlc/gui/browser/BaseBrowserFragment.kt |  3 ++-
 .../src/org/videolan/vlc/util/VersionMigration.kt       | 17 ++++++++++++++++-
 5 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index a7fca5e34..4bbfa79c4 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -324,7 +324,9 @@
     <string name="media_seen">Show seen video marker</string>
     <string name="media_seen_summary">Mark a video as seen when you play it until the end</string>
     <string name="force_play_all_summary">Play all videos, starting with the one you clicked on</string>
+    <string name="force_play_all_audio_summary">Play all audio, starting with the one you clicked on</string>
     <string name="force_play_all_title">Video playlist mode</string>
+    <string name="force_play_all_audio_title">Audio playlist mode</string>
     <string name="save_brightness_summary">Keep brightness level between media</string>
     <string name="save_brightness_title">Save brightness level</string>
     <string name="save_audiodelay_summary">Save individual audio delay for each video</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 8e84848ba..6529e49b3 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -110,6 +110,7 @@ const val PREF_WIDGETS_TIPS_SHOWN = "widgets_tips_shown"
 
 const val PREF_TV_UI = "tv_ui"
 const val FORCE_PLAY_ALL = "force_play_all"
+const val FORCE_PLAY_ALL_AUDIO = "force_play_all_audio"
 
 const val SCREEN_ORIENTATION = "screen_orientation"
 const val VIDEO_RESUME_TIME = "VideoResumeTime"
diff --git a/application/vlc-android/res/xml/preferences_ui.xml b/application/vlc-android/res/xml/preferences_ui.xml
index f2f61af97..dcd3db1db 100644
--- a/application/vlc-android/res/xml/preferences_ui.xml
+++ b/application/vlc-android/res/xml/preferences_ui.xml
@@ -82,6 +82,12 @@
                 android:key="audio_resume_card"
                 android:title="@string/audio_resume_card_title"
                 android:summary="@string/audio_resume_card_summary"/>
+        <CheckBoxPreference
+            app:singleLineTitle="false"
+            android:defaultValue="false"
+            android:key="force_play_all_audio"
+            android:summary="@string/force_play_all_audio_summary"
+            android:title="@string/force_play_all_audio_title"/>
         <CheckBoxPreference
                 app:singleLineTitle="false"
                 android:defaultValue="true"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 95e9c6f44..2377f8f21 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -526,7 +526,8 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
             mediaWrapper.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO)
             if (mediaWrapper.type == MediaWrapper.TYPE_DIR) browse(mediaWrapper, true)
             else {
-                if (!Settings.getInstance(requireContext()).getBoolean(FORCE_PLAY_ALL, false)) {
+                val forcePlayType = if (mediaWrapper.type == MediaWrapper.TYPE_VIDEO) FORCE_PLAY_ALL else FORCE_PLAY_ALL_AUDIO
+                if (!Settings.getInstance(requireContext()).getBoolean(forcePlayType, false)) {
                     lifecycleScope.launch {
                         MediaUtils.openMedia(requireContext(), getMediaWithMeta(item))
                     }
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 1d217b700..0969f329b 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
@@ -39,7 +39,7 @@ import org.videolan.vlc.gui.onboarding.ONBOARDING_DONE_KEY
 import java.io.File
 import java.io.IOException
 
-private const val CURRENT_VERSION = 7
+private const val CURRENT_VERSION = 8
 
 object VersionMigration {
 
@@ -67,6 +67,9 @@ object VersionMigration {
         if (lastVersion < 7) {
             migrateToVersion7(settings)
         }
+        if (lastVersion < 8) {
+            migrateToVersion8(settings)
+        }
 
         settings.putSingle(KEY_CURRENT_SETTINGS_VERSION, CURRENT_VERSION)
     }
@@ -177,4 +180,16 @@ object VersionMigration {
             settings.putSingle("video_repeat_mode", repeat)
         }
     }
+
+    /**
+     * Migrate from having one force_play_all that was labeled as Video Playlist Mode in the settings
+     * but also affected some audio in the browser to two separate settings force_play_all,
+     * historically will continue forcing to play all videos, and force_play_all_audio which will
+     * do the same when playing audio files. Migration to keep the previous value in both settings
+     */
+    private fun migrateToVersion8(settings: SharedPreferences) {
+        Log.i(this::class.java.simpleName, "Migration to Version 8: split force_play_all " +
+                "and add force_play_all_audio to separately handle video and audio")
+        settings.putSingle("force_play_all", settings.getBoolean("force_play_all", false))
+    }
 }
\ No newline at end of file



More information about the Android mailing list