Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
fix not sending track stop on next or previous track
Browse files Browse the repository at this point in the history
  • Loading branch information
KGT1 committed Oct 26, 2020
1 parent 84ad94a commit ea61bfb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ function seek (toSeek = 0) {
throw Error("No Song Playing");
}
}

function currentTrackStopped (itemId) {
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({
userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(),
itemId: itemId,
playSessionId: getPlaySessionId()
});
}
/**
*
* @param {Array} itemID - array of itemIDs to be added
Expand All @@ -123,12 +131,12 @@ function addTracks (itemID) {
}

function nextTrack () {
// console.log(currentPlayingPlaylistIndex + 1, currentPlayingPlaylist.length);
if (!(currentPlayingPlaylist)) {
throw Error("There is currently nothing playing");
} else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) {
throw Error("This is the Last song");
}
currentTrackStopped(getItemId());
startPlaying(undefined, undefined, currentPlayingPlaylistIndex + 1, 0, _disconnectOnFinish);
}

Expand All @@ -140,6 +148,7 @@ function previousTrack () {
startPlaying(undefined, undefined, currentPlayingPlaylistIndex, 0, _disconnectOnFinish);
throw Error("This is the First song");
}
currentTrackStopped(getItemId());
startPlaying(undefined, undefined, currentPlayingPlaylistIndex - 1, 0, _disconnectOnFinish);
}
}
Expand All @@ -155,11 +164,7 @@ function stop (disconnectVoiceConnection, itemId = getItemId()) {
if (disconnectVoiceConnection) {
disconnectVoiceConnection.disconnect();
}
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({
userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(),
itemId: itemId,
playSessionId: getPlaySessionId()
});
currentTrackStopped(itemId);
if (getAudioDispatcher()) {
try {
getAudioDispatcher().destroy();
Expand Down

0 comments on commit ea61bfb

Please sign in to comment.