[Android] Fix set value on background thread

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


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Sep  6 07:52:54 2024 +0200| [90bb1f598d1b594445696a2385023066c15689f3] | committer: Duncan McNamara

Fix set value on background thread

> https://code.videolan.org/videolan/vlc-android/commit/90bb1f598d1b594445696a2385023066c15689f3
---

 .../src/main/java/org/videolan/vlc/webserver/RemoteAccessServer.kt   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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 b6c773e86b..e6f160f04c 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
@@ -587,7 +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
+                var sleepTimer = 0L
+                scope.launch(Dispatchers.Main) {
+                    sleepTimer = playerSleepTime.value?.time?.time ?: 0L
+                }
                 val waitForMediaEnd = service.waitForMediaEnd
                 val resetOnInteraction = service.resetOnInteraction
                 val nowPlaying = NowPlaying(media.title ?: "", media.artist



More information about the Android mailing list