Skip to content

Commit

Permalink
use this.getPosition() because we want to fire an positionChanged eve…
Browse files Browse the repository at this point in the history
…nt if the media player interrupts or changes its current "direction".

added a getPosition output line at onSync in SpotifyListenerTest to debug its current calculated position
  • Loading branch information
LabyStudio committed Jan 9, 2024
1 parent 0327128 commit c2ee3fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void onTick() throws Exception {

// Handle position changes
int position = this.mediaPlayer.getPosition();
if (!this.hasPosition() || Math.abs(position - this.currentPosition) >= 1000) {
if (!this.hasPosition() || Math.abs(position - this.getPosition()) >= 1000) {
this.updatePosition(position);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ public Variant send(InterfaceMember interfaceMember, String... contents) throws
StringBuilder builder = new StringBuilder();
String response;
while ((response = reader.readLine()) != null) {
if (response.startsWith("method ")) continue;

if (response.startsWith("method ")) {
continue;
}
builder.append(response).append("\n");
}
if (builder.toString().isEmpty()) return new Variant("success", true);

if (builder.toString().isEmpty()) {
return new Variant("success", true);
}
return Variant.parse(builder.toString());
} else {
// Handle error message
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/SpotifyListenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void onPlayBackChanged(boolean isPlaying) {

@Override
public void onSync() {

// System.out.println(formatDuration(api.getPosition()));
}

@Override
Expand Down

0 comments on commit c2ee3fd

Please sign in to comment.