Commit 8ca0fec2 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

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.
parent 4f1afc90
...@@ -185,7 +185,7 @@ class PlaybackService : MediaBrowserServiceCompat() { ...@@ -185,7 +185,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
MediaPlayer.Event.EncounteredError -> executeUpdate() MediaPlayer.Event.EncounteredError -> executeUpdate()
MediaPlayer.Event.PositionChanged -> { MediaPlayer.Event.PositionChanged -> {
updateWidgetPosition(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())) { MediaPlayer.Event.ESAdded -> if (event.esChangedType == Media.Track.Type.Video && (playlistManager.videoBackground || !playlistManager.switchToVideo())) {
/* CbAction notification content intent: resume video or resume audio activity */ /* CbAction notification content intent: resume video or resume audio activity */
...@@ -622,10 +622,9 @@ class PlaybackService : MediaBrowserServiceCompat() { ...@@ -622,10 +622,9 @@ class PlaybackService : MediaBrowserServiceCompat() {
Toast.makeText(VLCApplication.getAppContext(), text, duration).show() Toast.makeText(VLCApplication.getAppContext(), text, duration).show()
} }
END_MEDIASESSION -> if (service::mediaSession.isInitialized) service.mediaSession.isActive = false END_MEDIASESSION -> if (service::mediaSession.isInitialized) service.mediaSession.isActive = false
PUBLISH_STATE -> { PUBLISH_PROGRESS -> {
val time = System.currentTimeMillis() val time = System.currentTimeMillis()
if (time - lastPublicationDate > 1000L) { if (time - lastPublicationDate > 1000L) {
service.publishState()
service.executeUpdateProgress() service.executeUpdateProgress()
lastPublicationDate = time lastPublicationDate = time
} }
...@@ -1333,7 +1332,7 @@ class PlaybackService : MediaBrowserServiceCompat() { ...@@ -1333,7 +1332,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
private const val SHOW_TOAST = 1 private const val SHOW_TOAST = 1
private const val END_MEDIASESSION = 2 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_DOUBLE_CLICK = 800L
internal const val DELAY_LONG_CLICK = 1000L internal const val DELAY_LONG_CLICK = 1000L
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment