report position ticks with playback stop

This commit is contained in:
KGT1 2020-11-20 10:42:21 +01:00
parent 9ec2d2aa73
commit e895e849a2

View File

@ -129,6 +129,8 @@ function nextTrack () {
} else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) { } else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) {
throw Error("This is the Last song"); throw Error("This is the Last song");
} }
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish); startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish);
} }
@ -140,6 +142,8 @@ function previousTrack () {
startPlaying(undefined, undefined, currentPlayingPlaylistIndex, 0, _disconnectOnFinish); startPlaying(undefined, undefined, currentPlayingPlaylistIndex, 0, _disconnectOnFinish);
throw Error("This is the First song"); throw Error("This is the First song");
} }
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish); startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish);
} }
} }
@ -155,11 +159,7 @@ function stop (disconnectVoiceConnection, itemId = getItemId()) {
if (disconnectVoiceConnection) { if (disconnectVoiceConnection) {
disconnectVoiceConnection.disconnect(); disconnectVoiceConnection.disconnect();
} }
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({ jellyfinClientManager.getJellyfinClient().reportPlaybackStopped(getStopPayload());
userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(),
itemId: itemId,
playSessionId: getPlaySessionId()
});
if (getAudioDispatcher()) { if (getAudioDispatcher()) {
try { try {
getAudioDispatcher().destroy(); getAudioDispatcher().destroy();
@ -285,6 +285,17 @@ function getProgressPayload () {
return payload; return payload;
} }
function getStopPayload () {
const payload = {
userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(),
itemId: getItemId(),
sessionID: getPlaySessionId(),
playSessionId: getPlaySessionId(),
positionTicks: getPostitionTicks()
};
return payload;
}
module.exports = { module.exports = {
startPlaying, startPlaying,
stop, stop,