Browse Source

Fix scrobble condition based on setting

master
jeffvli 3 years ago
parent
commit
bee7270312
  1. 98
      src/components/player/Player.tsx

98
src/components/player/Player.tsx

@ -337,57 +337,59 @@ const Player = ({ currentEntryList, muted, children }: any, ref: any) => {
}, [player.status]);
useEffect(() => {
setScrobbled(false); // Only scrobble a single time per song change
const currentSeek =
playQueue.currentPlayer === 1
? player1Ref.current.audioEl.current?.currentTime
: player2Ref.current.audioEl.current?.currentTime;
// Handle gapless players
if (playQueue.fadeDuration === 0 && currentSeek < 1) {
const timer = setTimeout(() => {
apiController({
serverType: config.serverType,
endpoint: 'scrobble',
args: {
id:
playQueue.currentPlayer === 1
? playQueue[currentEntryList][playQueue.player1.index]?.id
: playQueue[currentEntryList][playQueue.player2.index]?.id,
submission: false,
position: currentSeek * 10000000,
event: 'start',
},
});
}, 5000);
if (playQueue.scrobble) {
setScrobbled(false); // Only scrobble a single time per song change
return () => {
clearTimeout(timer);
};
}
const currentSeek =
playQueue.currentPlayer === 1
? player1Ref.current.audioEl.current?.currentTime
: player2Ref.current.audioEl.current?.currentTime;
// Handle crossfade players
if (playQueue.fadeDuration !== 0 && currentSeek < playQueue.fadeDuration + 1) {
const timer = setTimeout(() => {
apiController({
serverType: config.serverType,
endpoint: 'scrobble',
args: {
id:
playQueue.currentPlayer === 1
? playQueue[currentEntryList][playQueue.player1.index]?.id
: playQueue[currentEntryList][playQueue.player2.index]?.id,
submission: false,
position: currentSeek * 10000000,
event: 'start',
},
});
}, 5000);
// Handle gapless players
if (playQueue.fadeDuration === 0 && currentSeek < 1) {
const timer = setTimeout(() => {
apiController({
serverType: config.serverType,
endpoint: 'scrobble',
args: {
id:
playQueue.currentPlayer === 1
? playQueue[currentEntryList][playQueue.player1.index]?.id
: playQueue[currentEntryList][playQueue.player2.index]?.id,
submission: false,
position: currentSeek * 10000000,
event: 'start',
},
});
}, 5000);
return () => {
clearTimeout(timer);
};
return () => {
clearTimeout(timer);
};
}
// Handle crossfade players
if (playQueue.fadeDuration !== 0 && currentSeek < playQueue.fadeDuration + 1) {
const timer = setTimeout(() => {
apiController({
serverType: config.serverType,
endpoint: 'scrobble',
args: {
id:
playQueue.currentPlayer === 1
? playQueue[currentEntryList][playQueue.player1.index]?.id
: playQueue[currentEntryList][playQueue.player2.index]?.id,
submission: false,
position: currentSeek * 10000000,
event: 'start',
},
});
}, 5000);
return () => {
clearTimeout(timer);
};
}
}
return undefined;

Loading…
Cancel
Save