feat(web): send a "now playing" scrobble at track start
Ping Navidrome with scrobble?submission=false when a track starts so getNowPlaying reflects it instantly (feeds e.g. a Discord rich-presence plugin / other clients' Now Playing). Independent of the existing delayed "played" scrobble used for play counts and Last.fm. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f7d7740e4
commit
ddb9418603
1 file changed
+7
@@ -47,6 +47,12 @@ function _cancelScrobble() {
|
|||||||
function _scrobbleNow(s) {
|
function _scrobbleNow(s) {
|
||||||
if (s) api('scrobble', `&id=${s.id}&time=${Date.now()}`).catch(() => {});
|
if (s) api('scrobble', `&id=${s.id}&time=${Date.now()}`).catch(() => {});
|
||||||
}
|
}
|
||||||
|
// "Now Playing" ping (submission=false) — tells the server what's playing *right now* so
|
||||||
|
// getNowPlaying (and e.g. a Discord rich-presence plugin) updates instantly. This is distinct
|
||||||
|
// from the delayed "played" scrobble above, which counts the play for stats / Last.fm.
|
||||||
|
function _scrobbleNowPlaying(s) {
|
||||||
|
if (s) api('scrobble', `&id=${s.id}&submission=false`).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
// Unified duration / position / seek helpers — use native state when available,
|
// Unified duration / position / seek helpers — use native state when available,
|
||||||
// fall back to HTMLAudioElement when not.
|
// fall back to HTMLAudioElement when not.
|
||||||
@@ -404,6 +410,7 @@ export function playCurrent() {
|
|||||||
updateMediaSession(s);
|
updateMediaSession(s);
|
||||||
onNpSongChange(s.id);
|
onNpSongChange(s.id);
|
||||||
renderQueue();
|
renderQueue();
|
||||||
|
_scrobbleNowPlaying(s); // "läuft gerade" sofort an Navidrome (getNowPlaying)
|
||||||
_scheduleScrobble(s.id, s.duration);
|
_scheduleScrobble(s.id, s.duration);
|
||||||
|
|
||||||
const _resetFlag = () => { if (_playGen === gen) S._trackChanging = false; };
|
const _resetFlag = () => { if (_playGen === gen) S._trackChanging = false; };
|
||||||
|
|||||||
Reference in new issue
Block a user