[Android] Send broadcasts from threadpool

Geoffrey Métais git at videolan.org
Thu Jan 24 15:31:29 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 24 15:31:05 2019 +0100| [204a4044692f023c627b738cc80b9382a04332f0] | committer: Geoffrey Métais

Send broadcasts from threadpool

> https://code.videolan.org/videolan/vlc-android/commit/204a4044692f023c627b738cc80b9382a04332f0
---

 .../src/org/videolan/vlc/PlaybackService.kt        | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 48f8670c6..424fada3d 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -903,7 +903,7 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
             widgetIntent.putExtra("artist", "")
         }
         widgetIntent.putExtra("isplaying", isPlaying)
-        sendWidgetBroadcast(widgetIntent)
+        launch(Dispatchers.Default) { sendWidgetBroadcast(widgetIntent) }
     }
 
     private fun updateWidgetCover() {
@@ -911,8 +911,10 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
         val newWidgetCover = mw?.artworkMrl
         if (!TextUtils.equals(currentWidgetCover, newWidgetCover)) {
             currentWidgetCover = newWidgetCover
-            sendWidgetBroadcast(Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE_COVER)
-                    .putExtra("artworkMrl", newWidgetCover))
+            launch(Dispatchers.Default) {
+                sendWidgetBroadcast(Intent(VLCAppWidgetProvider.ACTION_WIDGET_UPDATE_COVER)
+                        .putExtra("artworkMrl", newWidgetCover))
+            }
         }
     }
 
@@ -931,13 +933,14 @@ class PlaybackService : MediaBrowserServiceCompat(), CoroutineScope, LifecycleOw
     private fun broadcastMetadata() {
         val media = playlistManager.getCurrentMedia()
         if (media == null || isVideoPlaying) return
-        sendBroadcast(Intent("com.android.music.metachanged")
-                .putExtra("track", media.title)
-                .putExtra("artist", media.artist)
-                .putExtra("album", media.album)
-                .putExtra("duration", media.length)
-                .putExtra("playing", isPlaying)
-                .putExtra("package", "org.videolan.vlc"))
+        launch(Dispatchers.Default) { sendBroadcast(Intent("com.android.music.metachanged")
+                    .putExtra("track", media.title)
+                    .putExtra("artist", media.artist)
+                    .putExtra("album", media.album)
+                    .putExtra("duration", media.length)
+                    .putExtra("playing", isPlaying)
+                    .putExtra("package", "org.videolan.vlc"))
+        }
     }
 
     private fun loadLastAudioPlaylist() {



More information about the Android mailing list