Raphix 2241136729
Some checks failed
Subsonics - Web/pipeline/head There was a failure building this commit
Subsonics - Web/pipeline/pr-main This commit looks good
Version 2.1.0 - Passage sur Lavalink V4 et Moonlink.js
2024-04-16 16:05:21 +02:00

53 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoonlinkTrack = void 0;
class MoonlinkTrack {
encoded;
identifier;
title;
author;
url;
duration;
position;
isSeekable;
isStream;
sourceName;
requester;
artworkUrl;
isrc;
time = 0;
constructor(data, requester) {
this.encoded = data.encoded;
this.title = data.info.title;
this.author = data.info.author;
this.url = data.info.uri;
this.duration = data.info.length;
this.position = data.info.position;
this.identifier = data.info.identifier;
this.isSeekable = Boolean(data.info.isSeekable);
this.isStream = Boolean(data.info.isStream);
this.sourceName = data.info.sourceName || null;
this.requester = requester;
this.artworkUrl = data.info.artworkUrl;
this.isrc = data.info.isrc;
}
get calculateRealTimePosition() {
if (this.position >= this.duration) {
return this.duration;
}
if (this.time) {
const elapsed = Date.now() - this.time;
const calculatedPosition = this.position + elapsed / 1000;
if (calculatedPosition >= this.duration) {
return this.duration;
}
return calculatedPosition;
}
return this.position;
}
setRequester(data) {
this.requester = data;
}
}
exports.MoonlinkTrack = MoonlinkTrack;