Skip to content

Commit 3b48042

Browse files
committed
fix another position desync on track change, version 1.1.3
1 parent 282309e commit 3b48042

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repositories {
2323
}
2424
2525
dependencies {
26-
implementation 'com.github.LabyStudio:java-spotify-api:1.1.2:all'
26+
implementation 'com.github.LabyStudio:java-spotify-api:1.1.3:all'
2727
}
2828
```
2929

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.1.2'
7+
version '1.1.3'
88

99
compileJava {
1010
sourceCompatibility = '1.8'

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected void onTick() {
6868

6969
// Reset position on song change
7070
if (!isFirstTrack) {
71-
this.updatePosition(0);
71+
this.updatePosition(0, true);
7272
}
7373
}
7474
}
@@ -86,7 +86,7 @@ protected void onTick() {
8686
int position = playback.getPosition();
8787
if (position != this.lastAccessorPosition) {
8888
this.lastAccessorPosition = position;
89-
this.updatePosition(position);
89+
this.updatePosition(position, false);
9090
}
9191

9292
// Fire keep alive
@@ -98,15 +98,15 @@ protected void onTick() {
9898
}
9999
}
100100

101-
private void updatePosition(int position) {
102-
if (position == this.currentPosition) {
101+
private void updatePosition(int position, boolean force) {
102+
if (position == this.currentPosition && !force) {
103103
return;
104104
}
105105

106106
// The position is known if the song is currently paused
107107
// or if the position has changed during the runtime of the program.
108-
// Because the position is updated when the track initializes, it could be that the position is not known yet.
109-
this.positionKnown = this.currentPosition != -1 || !this.isPlaying;
108+
// (The position update is also called when the memory content is empty)
109+
this.positionKnown = force || this.currentPosition != -1 || !this.isPlaying;
110110

111111
// Update position
112112
this.currentPosition = position;

0 commit comments

Comments
 (0)