scrobble: send now playing once per track change

A track transition resets the player position, and the scrobble policy's restart heuristic (same song, position drops to ~0) then re-announced the track we just left and, when the new track's position jittered back to zero, announced it twice. Suppress the now-playing when the restart is the same song; the submission logic still resets so a genuine replay is scrobbled again.
This commit is contained in:
austinried
2026-10-09 12:31:48 +00:00
parent ac1e62fc02
commit cfb663c250
2 changed files with 35 additions and 3 deletions
@@ -59,6 +59,7 @@ class ScrobblePolicy(
item?.id != songId ||
(item != null && item.id == lastItemId && positionMs < previousPosition && positionMs <= RESTART_POSITION_MS)
if (restarted) {
val sameSong = item != null && item.id == songId
songId = item?.id
lastItemId = null
playedMs = 0
@@ -68,7 +69,7 @@ class ScrobblePolicy(
if (item == null || !isPlaying) return null
nowPlayingSent = true
startedAt = now()
return Scrobble.NowPlaying(item.id)
return if (sameSong) null else Scrobble.NowPlaying(item.id)
}
lastPositionMs = positionMs
lastItemId = item?.id