diff --git a/res/layout/mpris_control.xml b/res/layout/mpris_control.xml
index 139f331c..52d466cf 100644
--- a/res/layout/mpris_control.xml
+++ b/res/layout/mpris_control.xml
@@ -20,6 +20,11 @@
android:id="@+id/no_players"
android:layout_gravity="center_horizontal" />
+
+
-1 && mpris.getPosition() > -1 && !"spotify".equals(mpris.getPlayer().toLowerCase())) {
diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
index be41600c..3fba2f39 100644
--- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisPlugin.java
@@ -22,10 +22,13 @@ package org.kde.kdeconnect.Plugins.MprisPlugin;
import android.app.Activity;
import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.support.v4.content.ContextCompat;
+import android.util.Base64;
import android.util.Log;
import org.kde.kdeconnect.NetworkPackage;
@@ -35,6 +38,8 @@ import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
import java.util.HashMap;
+import io.netty.handler.codec.base64.Base64Decoder;
+
public class MprisPlugin extends Plugin {
public final static String PACKAGE_TYPE_MPRIS = "kdeconnect.mpris";
@@ -43,6 +48,7 @@ public class MprisPlugin extends Plugin {
private String player = "";
private boolean playing = false;
private String currentSong = "";
+ private Bitmap currentArt;
private int volume = 50;
private long length = -1;
private long lastPosition;
@@ -120,7 +126,8 @@ public class MprisPlugin extends Plugin {
@Override
public boolean onPackageReceived(NetworkPackage np) {
- if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying") || np.has("length") || np.has("pos")) {
+ if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying") || np.has("length") ||
+ np.has("pos") || np.has("artImage")) {
if (np.getString("player").equals(player)) {
currentSong = np.getString("nowPlaying", currentSong);
volume = np.getInt("volume", volume);
@@ -129,6 +136,11 @@ public class MprisPlugin extends Plugin {
lastPosition = np.getLong("pos", lastPosition);
lastPositionTime = System.currentTimeMillis();
}
+ if (np.has("artImage")) {
+ String base64Image = np.getString("artImage");
+ byte[] decodedBytes = Base64.decode(base64Image, 0);
+ currentArt = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
+ }
playing = np.getBoolean("isPlaying", playing);
for (String key : playerStatusUpdated.keySet()) {
try {
@@ -208,6 +220,7 @@ public class MprisPlugin extends Plugin {
if (player == null || player.equals(this.player)) return;
this.player = player;
currentSong = "";
+ currentArt = null;
volume = 50;
playing = false;
for (String key : playerStatusUpdated.keySet()) {
@@ -230,6 +243,8 @@ public class MprisPlugin extends Plugin {
return currentSong;
}
+ public Bitmap getCurrentArt() { return currentArt; }
+
public String getPlayer() {
return player;
}