From 2620b6a8f639f6c1b483ae73b2571b5a3133ceab Mon Sep 17 00:00:00 2001 From: Kurt Aaholst Date: Wed, 12 Jun 2024 17:22:51 +0200 Subject: [PATCH] Fix current time second when not playing --- .../java/uk/org/ngo/squeezer/model/PlayerState.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/model/PlayerState.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/model/PlayerState.java index 2e9ee161c..78b556871 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/model/PlayerState.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/model/PlayerState.java @@ -308,9 +308,13 @@ public long getPosition() { } private double calcPosition() { - double now = SystemClock.elapsedRealtime() / 1000.0; - double trackCorrection = rate * (now - statusSeen); - return trackCorrection <= 0 ? currentTimeSecond : currentTimeSecond + trackCorrection; + if (isPlaying()) { + double now = SystemClock.elapsedRealtime() / 1000.0; + double trackCorrection = rate * (now - statusSeen); + return trackCorrection <= 0 ? currentTimeSecond : currentTimeSecond + trackCorrection; + } else { + return currentTimeSecond; + } } public int getCurrentSongDuration() {