Commit 72fbd3b0 authored by Geoffrey Métais's avatar Geoffrey Métais

Do not constantly publish mediasession progress

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

Auto and Now Playing card fake this progress, it was not needed at all.
parent 67fbad57
......@@ -113,7 +113,7 @@ public class PlaybackService extends MediaBrowserServiceCompat{
private static final int SHOW_PROGRESS = 0;
private static final int SHOW_TOAST = 1;
private static final int END_MEDIASESSION = 2;
private static final int PUBLISH_STATE = 3;
private static final int PUBLISH_PROGRESS = 3;
private static final long DELAY_DOUBLE_CLICK = 800L;
private static final long DELAY_LONG_CLICK = 1000L;
......@@ -547,8 +547,7 @@ public class PlaybackService extends MediaBrowserServiceCompat{
case MediaPlayer.Event.TimeChanged:
break;
case MediaPlayer.Event.PositionChanged:
updateWidgetPosition(event.getPositionChanged());
mHandler.sendEmptyMessage(PUBLISH_STATE);
if (mWidget != 0) mHandler.obtainMessage(PUBLISH_PROGRESS, event.getPositionChanged());
break;
case MediaPlayer.Event.Vout:
break;
......@@ -642,10 +641,10 @@ public class PlaybackService extends MediaBrowserServiceCompat{
case END_MEDIASESSION:
if (service.mMediaSession != null) service.mMediaSession.setActive(false);
break;
case PUBLISH_STATE:
case PUBLISH_PROGRESS:
final long time = System.currentTimeMillis();
if (time - lastPublicationDate > 1000L) {
service.publishState();
service.updateWidgetPosition((Float) msg.obj);
lastPublicationDate = time;
}
break;
......
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