···9090 duration,
9191 } = {}
9292 } = this.currentPlay;
9393- if(duration !== undefined && (duration - this.currentListenRange.end.position) < this.gracefulEndBuffer) {
9393+ if(duration !== undefined && duration !== 0 && (duration - this.currentListenRange.end.position) < this.gracefulEndBuffer) {
9494 // likely the track was listened to until it ended
9595 // but polling interval or network delays caused MS to not get data on the very end
9696 // also...within 3 seconds of ending is close enough to call this complete IMO
+23
src/backend/tests/player/player.test.ts
···257257 assert.equal(player.getListenDuration(), 7);
258258 });
259259260260+ it('Listened for is track duration invariant', function () {
261261+ const player = new TestPositionalPlayerState(logger, [NO_DEVICE, NO_USER]);
262262+263263+ const positioned = clone(newPlay);
264264+ positioned.data.duration = 0;
265265+266266+ player.update(testState({play: positioned, position: 3, status: REPORTED_PLAYER_STATUSES.playing}));
267267+268268+ player.currentListenRange.rtPlayer.setPosition(10000);
269269+ player.update(testState({play: positioned, position: 10, status: REPORTED_PLAYER_STATUSES.playing}), dayjs().add(10, 'seconds'));
270270+271271+ player.currentListenRange.rtPlayer.setPosition(20000);
272272+ player.update(testState({play: positioned, position: 20, status: REPORTED_PLAYER_STATUSES.playing}), dayjs().add(20, 'seconds'));
273273+274274+ const otherPlay = clone(positioned);
275275+ otherPlay.data.track = "A New Track";
276276+ player.currentListenRange.rtPlayer.setPosition(30000);
277277+ const [currPlay, prevPlay] = player.update(testState({play: otherPlay, position: 2, status: REPORTED_PLAYER_STATUSES.playing}), dayjs().add(30, 'seconds'));
278278+279279+ assert.isDefined(prevPlay);
280280+ assert.equal(prevPlay.data.listenedFor, 17);
281281+ });
282282+260283 it('Range ends if position over drifts', function () {
261284 const player = new TestPositionalPlayerState(logger, [NO_DEVICE, NO_USER]);
262285