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.8 kB · 40 lines
TypeScript
at database
1234567891011121314151617181920212223242526272829303132333435363738394041import { Logger } from "@foxxmd/logging";import { CALCULATED_PLAYER_STATUSES, PlayPlatformId } from "../../common/infrastructure/Atomic.js";import { AbstractPlayerState, PlayerStateOptions } from "./AbstractPlayerState.js";import { PlayProgress } from "../../../core/Atomic.js";import { ListenProgress, ListenProgressTS } from "./ListenProgress.js";import { ListenRange, ListenRangeTS } from "./ListenRange.js";import { Dayjs } from "dayjs";
export class GenericPlayerState extends AbstractPlayerState { protected newListenProgress(data?: Partial<PlayProgress>): ListenProgress { return new ListenProgressTS(data); }
protected newListenRange(start?: ListenProgress, end?: ListenProgress, options?: object): ListenRange { return new ListenRangeTS(start, end); }
constructor(logger: Logger, platformId: PlayPlatformId, opts?: PlayerStateOptions) { super(logger, platformId, opts); } protected currentListenSessionContinue(position?: number, timestamp?: Dayjs) { if (this.currentListenRange === undefined) { this.logger.debug('Started new Player listen range.'); this.currentListenRange = this.newListenRange(this.newListenProgress({position, timestamp})); } else { this.calculatedStatus = CALCULATED_PLAYER_STATUSES.playing; this.currentListenRange.setRangeEnd(this.newListenProgress({position, timestamp})); } }
protected currentListenSessionEnd() { if (this.currentListenRange !== undefined && this.currentListenRange.getDuration() !== 0) { this.logger.debug('Ended current Player listen range.') this.currentListenRange.finalize(); this.listenRanges.push(this.currentListenRange); } this.currentListenRange = undefined; }}