mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 01:51:47 +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 url = "";
|
||||
private String loopStatus = "";
|
||||
private double rate = 1.0;
|
||||
private boolean loopStatusAllowed = false;
|
||||
private boolean shuffle = false;
|
||||
private boolean shuffleAllowed = false;
|
||||
@ -89,6 +90,10 @@ public class MprisPlugin extends Plugin {
|
||||
return loopStatus;
|
||||
}
|
||||
|
||||
public double getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public boolean getShuffle() {
|
||||
return shuffle;
|
||||
}
|
||||
@ -157,7 +162,7 @@ public class MprisPlugin extends Plugin {
|
||||
|
||||
public long getPosition() {
|
||||
if (playing) {
|
||||
return lastPosition + (System.currentTimeMillis() - lastPositionTime);
|
||||
return (int) Math.round(lastPosition + (System.currentTimeMillis() - lastPositionTime) * rate);
|
||||
} else {
|
||||
return lastPosition;
|
||||
}
|
||||
@ -201,6 +206,10 @@ public class MprisPlugin extends Plugin {
|
||||
MprisPlugin.this.sendCommand(getPlayer(), "setLoopStatus", loopStatus);
|
||||
}
|
||||
|
||||
public void setRate(double rate) {
|
||||
MprisPlugin.this.sendCommand(getPlayer(), "setRate", rate);
|
||||
}
|
||||
|
||||
public void setShuffle(boolean shuffle) {
|
||||
MprisPlugin.this.sendCommand(getPlayer(), "setShuffle", shuffle);
|
||||
}
|
||||
@ -326,6 +335,7 @@ public class MprisPlugin extends Plugin {
|
||||
playerStatus.loopStatus = np.getString("loopStatus", playerStatus.loopStatus);
|
||||
playerStatus.loopStatusAllowed = true;
|
||||
}
|
||||
playerStatus.rate = np.getDouble("rate", playerStatus.rate);
|
||||
if (np.has("shuffle")) {
|
||||
playerStatus.shuffle = np.getBoolean("shuffle", playerStatus.shuffle);
|
||||
playerStatus.shuffleAllowed = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user