Skip to content

Commit dd16cd9

Browse files
committed
Bump version to 1.4.3 and improve track position validation logic
1 parent 1196c75 commit dd16cd9

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'de.labystudio'
7-
version '1.4.0'
7+
version '1.4.3'
88

99
compileJava {
1010
sourceCompatibility = '1.8'

src/main/java/de/labystudio/spotifyapi/platform/windows/WinSpotifyAPI.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class WinSpotifyAPI extends AbstractTickSpotifyAPI {
2424

2525
private Track currentTrack;
2626
private int currentPosition = -1;
27+
private boolean hasTrackPosition = false;
2728
private boolean isPlaying;
2829

2930
private long lastTimePositionUpdated;
@@ -102,8 +103,11 @@ protected void onTick() {
102103
this.listeners.forEach(listener -> listener.onPositionChanged(this.currentPosition));
103104
}
104105
}
106+
107+
this.hasTrackPosition = true;
105108
} else {
106109
this.currentPosition = -1;
110+
this.hasTrackPosition = false;
107111
this.lastTimePositionUpdated = System.currentTimeMillis();
108112
}
109113

@@ -142,9 +146,7 @@ public boolean hasPosition() {
142146
if (!this.isConnected()) {
143147
return false;
144148
}
145-
146-
PlaybackAccessor playback = this.process.getMainPlaybackAccessor();
147-
return playback.hasTrackPosition();
149+
return this.hasTrackPosition;
148150
}
149151

150152
@Override

src/main/java/de/labystudio/spotifyapi/platform/windows/api/playback/PlaybackAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ default boolean hasTrackLength() {
1616
}
1717

1818
default boolean hasTrackPosition() {
19-
return this.getPosition() >= 0 && (!this.hasTrackLength() || this.getPosition() <= this.getLength());
19+
return this.getPosition() >= 0 && this.hasTrackLength() && this.getPosition() <= this.getLength();
2020
}
2121
}
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)