Open nouste opened 8 years ago
Indeed, we would need much better book keeping to get this right. Probably we can do something like the following:
on-track-start:
last_position = 0
played_time = 0
on-seek:
played_time += current_position - last_position
last_position = seek_position
on-track-change:
played_time += current_position - last_position
if played_time > ...:
scrobble()
We could also consider if this is something that mopidy should / could keep track of instead of leaving it to extensions.
Having looked at this due to other reason, I don't think we have a sane way of getting current_position
without changing something in core.
The extension does not count the actual time a track has been played, but only checks the time position at the end of playback to do the math. The problem in this approach is that after a track has started to play and someone jumps past the half duration of the track (or past 240 seconds) and then skips to next track, the track will be scrobbled no matter how long it has been played.
I found this issue when I had a couple of new albums on my playlist which I just quickly skipped through while listening a few seconds here and there from each track. To my surprise I later noticed that all of the tracks had been scrobbled.