mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 09:58:08 +00:00
Add support for MPRIS playback rate
This will ensure that the extrapolated play position will be correct for playback rates other than 1.0.
This commit is contained in:
parent
e409ec37eb
commit
3274f54fdd
@ -44,6 +44,7 @@ public class MprisPlugin extends Plugin {
|
|||||||
private String albumArtUrl = "";
|
private String albumArtUrl = "";
|
||||||
private String url = "";
|
private String url = "";
|
||||||
private String loopStatus = "";
|
private String loopStatus = "";
|
||||||
|
private double rate = 1.0;
|
||||||
private boolean loopStatusAllowed = false;
|
private boolean loopStatusAllowed = false;
|
||||||
private boolean shuffle = false;
|
private boolean shuffle = false;
|
||||||
private boolean shuffleAllowed = false;
|
private boolean shuffleAllowed = false;
|
||||||
@ -89,6 +90,10 @@ public class MprisPlugin extends Plugin {
|
|||||||
return loopStatus;
|
return loopStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getRate() {
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getShuffle() {
|
public boolean getShuffle() {
|
||||||
return shuffle;
|
return shuffle;
|
||||||
}
|
}
|
||||||
@ -157,7 +162,7 @@ public class MprisPlugin extends Plugin {
|
|||||||
|
|
||||||
public long getPosition() {
|
public long getPosition() {
|
||||||
if (playing) {
|
if (playing) {
|
||||||
return lastPosition + (System.currentTimeMillis() - lastPositionTime);
|
return (int) Math.round(lastPosition + (System.currentTimeMillis() - lastPositionTime) * rate);
|
||||||
} else {
|
} else {
|
||||||
return lastPosition;
|
return lastPosition;
|
||||||
}
|
}
|
||||||
@ -201,6 +206,10 @@ public class MprisPlugin extends Plugin {
|
|||||||
MprisPlugin.this.sendCommand(getPlayer(), "setLoopStatus", loopStatus);
|
MprisPlugin.this.sendCommand(getPlayer(), "setLoopStatus", loopStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRate(double rate) {
|
||||||
|
MprisPlugin.this.sendCommand(getPlayer(), "setRate", rate);
|
||||||
|
}
|
||||||
|
|
||||||
public void setShuffle(boolean shuffle) {
|
public void setShuffle(boolean shuffle) {
|
||||||
MprisPlugin.this.sendCommand(getPlayer(), "setShuffle", shuffle);
|
MprisPlugin.this.sendCommand(getPlayer(), "setShuffle", shuffle);
|
||||||
}
|
}
|
||||||
@ -326,6 +335,7 @@ public class MprisPlugin extends Plugin {
|
|||||||
playerStatus.loopStatus = np.getString("loopStatus", playerStatus.loopStatus);
|
playerStatus.loopStatus = np.getString("loopStatus", playerStatus.loopStatus);
|
||||||
playerStatus.loopStatusAllowed = true;
|
playerStatus.loopStatusAllowed = true;
|
||||||
}
|
}
|
||||||
|
playerStatus.rate = np.getDouble("rate", playerStatus.rate);
|
||||||
if (np.has("shuffle")) {
|
if (np.has("shuffle")) {
|
||||||
playerStatus.shuffle = np.getBoolean("shuffle", playerStatus.shuffle);
|
playerStatus.shuffle = np.getBoolean("shuffle", playerStatus.shuffle);
|
||||||
playerStatus.shuffleAllowed = true;
|
playerStatus.shuffleAllowed = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user