[Android] Do not constantly publish mediasession progress

Geoffrey Métais git at videolan.org
Fri May 4 09:53:18 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May  4 09:51:34 2018 +0200| [8ca0fec278533f828f37461b1f918d46345fb73b] | committer: Geoffrey Métais

Do not constantly publish mediasession progress

This was spamming the all framework for unnecessary updates.
Especially Android Auto via Bluetooth.

Auto and Now Playing card fake this progress, it was not needed at all.

> https://code.videolan.org/videolan/vlc-android/commit/8ca0fec278533f828f37461b1f918d46345fb73b
---

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

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 9eef6755b..aba2146f6 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -185,7 +185,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
             MediaPlayer.Event.EncounteredError -> executeUpdate()
             MediaPlayer.Event.PositionChanged -> {
                 updateWidgetPosition(event.positionChanged)
-                handler.sendEmptyMessage(PUBLISH_STATE)
+                handler.sendEmptyMessage(PUBLISH_PROGRESS)
             }
             MediaPlayer.Event.ESAdded -> if (event.esChangedType == Media.Track.Type.Video && (playlistManager.videoBackground || !playlistManager.switchToVideo())) {
                 /* CbAction notification content intent: resume video or resume audio activity */
@@ -622,10 +622,9 @@ class PlaybackService : MediaBrowserServiceCompat() {
                     Toast.makeText(VLCApplication.getAppContext(), text, duration).show()
                 }
                 END_MEDIASESSION -> if (service::mediaSession.isInitialized) service.mediaSession.isActive = false
-                PUBLISH_STATE -> {
+                PUBLISH_PROGRESS -> {
                     val time = System.currentTimeMillis()
                     if (time - lastPublicationDate > 1000L) {
-                        service.publishState()
                         service.executeUpdateProgress()
                         lastPublicationDate = time
                     }
@@ -1333,7 +1332,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
 
         private const val SHOW_TOAST = 1
         private const val END_MEDIASESSION = 2
-        private const val PUBLISH_STATE = 3
+        private const val PUBLISH_PROGRESS = 3
 
         internal const val DELAY_DOUBLE_CLICK = 800L
         internal const val DELAY_LONG_CLICK = 1000L



More information about the Android mailing list