[Android] Fix the default sleep timer being not applied

Nicolas Pomepuy git at videolan.org
Tue Jun 11 14:50:39 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jun 10 09:14:36 2024 +0200| [4294ab403b75b28d9f9f2c8457b8521c1b4cd2f2] | committer: Nicolas Pomepuy

Fix the default sleep timer being not applied

> https://code.videolan.org/videolan/vlc-android/commit/4294ab403b75b28d9f9f2c8457b8521c1b4cd2f2
---

 .../src/org/videolan/vlc/media/PlaylistManager.kt            | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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 5a7609a723..634fcfbfd0 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -68,6 +68,9 @@ import org.videolan.tools.POSITION_IN_AUDIO_LIST
 import org.videolan.tools.POSITION_IN_MEDIA
 import org.videolan.tools.POSITION_IN_MEDIA_LIST
 import org.videolan.tools.POSITION_IN_SONG
+import org.videolan.tools.SLEEP_TIMER_DEFAULT_INTERVAL
+import org.videolan.tools.SLEEP_TIMER_DEFAULT_RESET_INTERACTION
+import org.videolan.tools.SLEEP_TIMER_DEFAULT_WAIT
 import org.videolan.tools.Settings
 import org.videolan.tools.VIDEO_PAUSED
 import org.videolan.tools.VIDEO_RESUME_PLAYBACK
@@ -90,6 +93,7 @@ import org.videolan.vlc.util.updateNextProgramAfterThumbnailGeneration
 import org.videolan.vlc.util.updateWithMLMeta
 import org.videolan.vlc.util.validateLocation
 import java.security.SecureRandom
+import java.util.Calendar
 import java.util.Stack
 import kotlin.math.max
 
@@ -268,6 +272,14 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             service.showNotification()
         }
         if (settings.getBoolean(KEY_AUDIO_FORCE_SHUFFLE, false) && getCurrentMedia()?.type == MediaWrapper.TYPE_AUDIO && !shuffling && canShuffle()) shuffle()
+        if (settings.getLong(SLEEP_TIMER_DEFAULT_INTERVAL, -1L) != -1L) {
+            service.waitForMediaEnd = settings.getBoolean(SLEEP_TIMER_DEFAULT_WAIT, false)
+            service.resetOnInteraction = settings.getBoolean(SLEEP_TIMER_DEFAULT_RESET_INTERACTION, false)
+            val sleepTime = Calendar.getInstance()
+            sleepTime.timeInMillis += settings.getLong(SLEEP_TIMER_DEFAULT_INTERVAL, -1L)
+            sleepTime.set(Calendar.SECOND, 0)
+            service.setSleepTimer(sleepTime)
+        }
     }
 
     @Volatile



More information about the Android mailing list