Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
1.4 kB · 38 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738import type {SourcePlayerObj} from "../../../core/Atomic.ts";import { GenericPlayerState } from "./GenericPlayerState.ts";
/** * This Player is only used for displaying data reported to EndpointListenbrainzSource, and parsed from ListenbrainzSource, as playing_now * and the behvior for Listenbrainz server is to display playing now info with a timeout equal to duraion of the submitted track * https://github.com/FoxxMD/multi-scrobbler/discussions/338 * * We'll use duration as a generic timeout for any Source that *only* parses Now Playing data for Player */export class NowPlayingPlayerState extends GenericPlayerState {
protected getStaleInterval() { if(this.currentPlay !== undefined && this.currentPlay.data.duration !== undefined) { return this.currentPlay.data.duration; } return super.getStaleInterval(); }
protected getOrphanedInterval() { if(this.currentPlay !== undefined && this.currentPlay.data.duration !== undefined) { // want this player to clear Now Playing as soon as track is finished return (this.currentPlay.data.duration / 2) + 1; } return super.getOrphanedInterval(); }
public isDead() { return this.isOrphaned(); }
public getApiState(): SourcePlayerObj { const data = super.getApiState(); data.nowPlayingMode = true; return data; }
}