[Android] Persist video repeat mode + setting
Nicolas Pomepuy
git at videolan.org
Tue Sep 10 15:11:04 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Aug 26 08:10:24 2019 +0200| [4b10f9f1f64968b1c11cc0f6435c02330b458e35] | committer: Geoffrey Métais
Persist video repeat mode + setting
> https://code.videolan.org/videolan/vlc-android/commit/4b10f9f1f64968b1c11cc0f6435c02330b458e35
---
vlc-android/res/values/strings.xml | 1 +
vlc-android/res/xml/preferences_video.xml | 7 +++++++
vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 11 +++++++++--
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 62885e76e..8a1a32535 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -376,6 +376,7 @@
<string name="list_title_ellipsize_marquee">Marquee</string>
<string name="audio_save_repeat_title">Save repeat mode</string>
<string name="audio_save_repeat_summary">Remember repeat mode when loading audio playlists</string>
+ <string name="video_save_repeat_summary">Remember repeat mode when loading video playlists</string>
<string name="audio_boost_title">Audio-boost</string>
<string name="audio_boost_summary">Allow volume up to 200%</string>
<string name="headset_prefs_category">Headset</string>
diff --git a/vlc-android/res/xml/preferences_video.xml b/vlc-android/res/xml/preferences_video.xml
index 193d674f5..d3b537061 100644
--- a/vlc-android/res/xml/preferences_video.xml
+++ b/vlc-android/res/xml/preferences_video.xml
@@ -48,6 +48,13 @@
android:summary="@string/confirm_resume_summary"
android:title="@string/confirm_resume_title"/>
+ <CheckBoxPreference
+ app:singleLineTitle="false"
+ android:defaultValue="false"
+ android:key="video_save_repeat"
+ android:summary="@string/video_save_repeat_summary"
+ android:title="@string/audio_save_repeat_title" />
+
<PreferenceCategory android:title="@string/controls_prefs_category">
<CheckBoxPreference
app:singleLineTitle="false"
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 32a088e99..8fc3450ac 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -31,6 +31,7 @@ import kotlin.math.max
private const val TAG = "VLC/PlaylistManager"
private const val PREVIOUS_LIMIT_DELAY = 5000L
private const val AUDIO_REPEAT_MODE_KEY = "audio_repeat_mode"
+private const val VIDEO_REPEAT_MODE_KEY = "video_repeat_mode"
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
@@ -75,8 +76,11 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
fun isValidPosition(position: Int) = position in 0 until mediaList.size()
- init {
- if (settings.getBoolean("audio_save_repeat", false)) repeating = settings.getInt(AUDIO_REPEAT_MODE_KEY, REPEAT_NONE)
+ private fun computeRepeating() {
+ if (isAudioList())
+ if (settings.getBoolean("audio_save_repeat", false)) repeating = settings.getInt(AUDIO_REPEAT_MODE_KEY, REPEAT_NONE)
+ else
+ if (settings.getBoolean("video_save_repeat", false)) repeating = settings.getInt(VIDEO_REPEAT_MODE_KEY, REPEAT_NONE)
}
/**
@@ -258,6 +262,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
repeating = repeatType
if (isAudioList() && settings.getBoolean("audio_save_repeat", false))
settings.edit().putInt(AUDIO_REPEAT_MODE_KEY, repeating).apply()
+ else if (!isAudioList() && settings.getBoolean("video_save_repeat", false))
+ settings.edit().putInt(VIDEO_REPEAT_MODE_KEY, repeating).apply()
savePosition()
launch { determinePrevAndNextIndices() }
}
@@ -332,6 +338,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
@MainThread
fun switchToVideo(): Boolean {
val media = getCurrentMedia()
+ computeRepeating()
if (media === null || media.hasFlag(AbstractMediaWrapper.MEDIA_FORCE_AUDIO) || !player.canSwitchToVideo())
return false
val hasRenderer = player.hasRenderer
More information about the Android
mailing list