[Android] Prevent PlaybackService loading notification bug

Nicolas Pomepuy git at videolan.org
Tue May 26 13:41:00 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue May 26 09:32:11 2020 +0200| [7b25c89213533581df195030fc2cacda3f2bf91e] | committer: Geoffrey Métais

Prevent PlaybackService loading notification bug

Fixes #1354

> https://code.videolan.org/videolan/vlc-android/commit/7b25c89213533581df195030fc2cacda3f2bf91e
---

 application/vlc-android/src/org/videolan/vlc/PlaybackService.kt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index ac92a43b4..3e0b91aa8 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -457,9 +457,9 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
     @RequiresApi(Build.VERSION_CODES.O)
     override fun onCreate() {
         dispatcher.onServicePreSuperOnCreate()
+        setupScope()
         forceForeground()
         super.onCreate()
-        setupScope()
         NotificationHelper.createNotificationChannels(applicationContext)
         settings = Settings.getInstance(this)
         playlistManager = PlaylistManager(this)
@@ -588,13 +588,13 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
     private fun forceForeground() {
         if (!AndroidUtil.isOOrLater || isForeground) return
         val ctx = applicationContext
-        val stopped = PlayerController.playbackState == PlaybackStateCompat.STATE_STOPPED
+        val stopped = PlayerController.playbackState == PlaybackStateCompat.STATE_STOPPED || PlayerController.playbackState == PlaybackStateCompat.STATE_NONE
         val notification = if (this::notification.isInitialized && !stopped) notification
         else {
             val pi = if (::playlistManager.isInitialized) sessionPendingIntent else null
             NotificationHelper.createPlaybackNotification(ctx, false,
-                ctx.resources.getString(R.string.loading), "", "", null,
-                false, true, null, pi)
+                    ctx.resources.getString(R.string.loading), "", "", null,
+                    false, true, null, pi)
         }
         startForeground(3, notification)
         isForeground = true



More information about the Android mailing list