diff --git a/res/layout/mpris_control.xml b/res/layout/mpris_control.xml index 3c4cf03c..5a0b8e83 100644 --- a/res/layout/mpris_control.xml +++ b/res/layout/mpris_control.xml @@ -88,6 +88,39 @@ + + + + + + + + + playerList = new ArrayList(); @@ -50,6 +53,8 @@ public class MprisPlugin extends Plugin { private String player = ""; private boolean playing = false; + + @Override public String getPluginName() { return "plugin_mpris"; @@ -83,6 +88,7 @@ public class MprisPlugin extends Plugin { @Override public boolean onCreate() { requestPlayerList(); + lastPositionTime = System.currentTimeMillis(); return true; } @@ -97,7 +103,6 @@ public class MprisPlugin extends Plugin { np.set("action",s); device.sendPackage(np); } - public void setVolume(int volume) { NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_MPRIS); np.set("player",player); @@ -105,6 +110,15 @@ public class MprisPlugin extends Plugin { device.sendPackage(np); } + public void setPosition(int position) { + NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_MPRIS); + np.set("player",player); + np.set("SetPosition", position); + device.sendPackage(np); + this.lastPosition = position; + this.lastPositionTime = System.currentTimeMillis(); + } + public void Seek(int offset) { NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_MPRIS); np.set("player",player); @@ -116,10 +130,15 @@ public class MprisPlugin extends Plugin { public boolean onPackageReceived(NetworkPackage np) { if (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_MPRIS)) return false; - if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying")) { + if (np.has("nowPlaying") || np.has("volume") || np.has("isPlaying") || np.has("length") || np.has("pos")) { if (np.getString("player").equals(player)) { currentSong = np.getString("nowPlaying", currentSong); volume = np.getInt("volume", volume); + length = np.getInt("length", length); + if(np.has("pos")){ + lastPosition = np.getInt("pos", lastPosition); + lastPositionTime = System.currentTimeMillis(); + } playing = np.getBoolean("isPlaying", playing); if (playerStatusUpdated != null) { try { @@ -208,10 +227,20 @@ public class MprisPlugin extends Plugin { return volume; } + public int getLength(){ return length; } + public boolean isPlaying() { return playing; } + public int getPosition(){ + + if(playing) + return lastPosition + (int)(System.currentTimeMillis() - lastPositionTime)*1000; + else + return lastPosition; + } + private void requestPlayerList() { NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_MPRIS); np.set("requestPlayerList",true);