From e895e849a29018f7ce3a99ac724da7cf83442cac Mon Sep 17 00:00:00 2001 From: KGT1 Date: Fri, 20 Nov 2020 10:42:21 +0100 Subject: [PATCH] report position ticks with playback stop --- src/playbackmanager.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/playbackmanager.js b/src/playbackmanager.js index 88fc29b..464cad5 100644 --- a/src/playbackmanager.js +++ b/src/playbackmanager.js @@ -129,6 +129,8 @@ function nextTrack () { } else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) { throw Error("This is the Last song"); } + jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload()); + startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish); } @@ -140,6 +142,8 @@ function previousTrack () { startPlaying(undefined, undefined, currentPlayingPlaylistIndex, 0, _disconnectOnFinish); throw Error("This is the First song"); } + jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload()); + startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish); } } @@ -155,11 +159,7 @@ function stop (disconnectVoiceConnection, itemId = getItemId()) { if (disconnectVoiceConnection) { disconnectVoiceConnection.disconnect(); } - jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({ - userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(), - itemId: itemId, - playSessionId: getPlaySessionId() - }); + jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload()); if (getAudioDispatcher()) { try { getAudioDispatcher().destroy(); @@ -285,6 +285,17 @@ function getProgressPayload () { return payload; } +function getStopPayload () { + const payload = { + userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(), + itemId: getItemId(), + sessionID: getPlaySessionId(), + playSessionId: getPlaySessionId(), + positionTicks: getPostitionTicks() + }; + return payload; +} + module.exports = { startPlaying, stop,