[Android] Fix Medialibrary pause and resume actions

Nicolas Pomepuy git at videolan.org
Tue Jul 20 12:05:35 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jul 20 06:22:49 2021 +0200| [4e21f5d05e2af21a4665a74a4c807ede1f38925f] | committer: Nicolas Pomepuy

Fix Medialibrary pause and resume actions

Fixes #2013

> https://code.videolan.org/videolan/vlc-android/commit/4e21f5d05e2af21a4665a74a4c807ede1f38925f
---

 .../vlc-android/src/org/videolan/vlc/MediaParsingService.kt        | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index b6ca7006e..79f054248 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -88,6 +88,8 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
     private var inDiscovery = false
     private lateinit var actions : SendChannel<MLAction>
     private lateinit var notificationActor : SendChannel<Notification>
+    var lastDone = -1
+    var lastScheduled = -1
 
     private val exceptionHandler = if (BuildConfig.BETA) Medialibrary.MedialibraryExceptionHandler { context, errMsg, _ ->
         val intent = Intent(applicationContext, SendCrashActivity::class.java).apply {
@@ -136,7 +138,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
 
         if (lastNotificationTime == 5L) stopService(Intent(applicationContext, MediaParsingService::class.java))
         Medialibrary.getState().observe(this, { running ->
-            if (!running && !scanPaused) {
+            if (!running) {
                 exitCommand()
             }
         })
@@ -389,6 +391,8 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
     }
 
     override fun onParsingStatsUpdated(done: Int, scheduled:Int) {
+        lastDone = done
+        lastScheduled = scheduled
         parsing = (done.toFloat() / scheduled.toFloat() * 100F)
         if (parsing != 100F && ::notificationActor.isInitialized) notificationActor.safeOffer(Show(done, scheduled))
     }
@@ -495,6 +499,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
                     scanPaused = false
                 }
             }
+            notificationActor.safeOffer(Show(lastDone, lastScheduled))
         }
     }
 



More information about the Android mailing list