[Android] Remote access: send the sleep timer value

Nicolas Pomepuy git at videolan.org
Mon Sep 9 15:14:15 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Aug 13 09:55:27 2024 +0200| [9757024c9ddc0e014629afcfb8c15545e368e507] | committer: Duncan McNamara

Remote access: send the sleep timer value

> https://code.videolan.org/videolan/vlc-android/commit/9757024c9ddc0e014629afcfb8c15545e368e507
---

 application/resources/src/main/res/values/strings.xml               | 1 +
 .../src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt  | 6 ++++--
 .../src/main/java/org/videolan/vlc/webserver/TranslationMapping.kt  | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index c0dc94d07a..650a8ab06f 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -602,6 +602,7 @@
     <string name="playlist_save">Save Playlist</string>
     <string name="playlist_name_hint">Playlist name</string>
     <string name="chapters">Chapters</string>
+    <string name="notset">Not set</string>
     <string name="go_to_chapter">Go to chapter…</string>
     <string name="current_chapter">Chapter: %s</string>
     <string name="confirm_resume">Resume from last position?</string>
diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt
index 036bd388ce..748780d786 100644
--- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt
+++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt
@@ -97,6 +97,7 @@ import org.videolan.tools.SingletonHolder
 import org.videolan.tools.livedata.LiveDataset
 import org.videolan.tools.putSingle
 import org.videolan.vlc.PlaybackService
+import org.videolan.vlc.PlaybackService.Companion.playerSleepTime
 import org.videolan.vlc.gui.DialogActivity
 import org.videolan.vlc.media.PlaylistManager
 import org.videolan.vlc.providers.NetworkProvider
@@ -586,9 +587,10 @@ class RemoteAccessServer(private val context: Context) : PlaybackService.Callbac
                 val bookmarks = withContext(Dispatchers.IO) { media.bookmarks ?: arrayOf() }
                 val chapters = withContext(Dispatchers.IO) { service.getChapters(-1) ?: arrayOf() }
                 val speed = String.format(Locale.US, "%.2f", service.speed).toFloat()
+                val sleepTimer = playerSleepTime.value?.time?.time ?: 0L
                 val nowPlaying = NowPlaying(media.title ?: "", media.artist
                         ?: "", service.isPlaying, service.getTime(), service.length, media.id, media.artworkURL
-                        ?: "", media.uri.toString(), getVolume(), speed, service.isShuffling, service.repeatType, bookmarks = bookmarks.map { WSBookmark(it.title, it.time) }, chapters = chapters.map { WSBookmark(it.name, it.duration) })
+                        ?: "", media.uri.toString(), getVolume(), speed, sleepTimer, service.isShuffling, service.repeatType, bookmarks = bookmarks.map { WSBookmark(it.title, it.time) }, chapters = chapters.map { WSBookmark(it.name, it.duration) })
                 return nowPlaying
 
             }
@@ -740,7 +742,7 @@ class RemoteAccessServer(private val context: Context) : PlaybackService.Callbac
     }
 
     abstract class WSMessage(val type: String)
-    data class NowPlaying(val title: String, val artist: String, val playing: Boolean, val progress: Long, val duration: Long, val id: Long, val artworkURL: String, val uri: String, val volume: Int, val speed: Float, val shuffle: Boolean, val repeat: Int, val shouldShow: Boolean = PlaylistManager.playingState.value
+    data class NowPlaying(val title: String, val artist: String, val playing: Boolean, val progress: Long, val duration: Long, val id: Long, val artworkURL: String, val uri: String, val volume: Int, val speed: Float, val sleepTimer: Long, val shuffle: Boolean, val repeat: Int, val shouldShow: Boolean = PlaylistManager.playingState.value
             ?: false, val bookmarks:List<WSBookmark> = listOf(), val chapters:List<WSBookmark> = listOf()) : WSMessage("now-playing")
 
     data class WSBookmark(val title: String, val time: Long)
diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/TranslationMapping.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/TranslationMapping.kt
index 57565070c9..82e5f1d9d9 100644
--- a/application/webserver/src/main/java/org/videolan/vlc/webserver/TranslationMapping.kt
+++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/TranslationMapping.kt
@@ -129,5 +129,6 @@ object TranslationMapping {
         PLAYBACK_SPEED(R.string.playback_speed),
         CHAPTERS(R.string.chapters),
         BOOKMARKS(R.string.bookmarks),
+        NOT_SET(R.string.notset),
     }
 }
\ No newline at end of file



More information about the Android mailing list