From 9a1d0c26338a7d0851c60b99296669cdc80673f2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 14 May 2023 19:53:31 -0300 Subject: new GhostPlayer class & support 👻 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also makes the UI not explode when duration strings aren't available for progress bar display, and shows getTimeStringsFromSec how to handle that. --- backend.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'backend.js') diff --git a/backend.js b/backend.js index ed89133..93de487 100644 --- a/backend.js +++ b/backend.js @@ -660,6 +660,12 @@ class QueuePlayer extends EventEmitter { this.emit('set-loop-queue-at-end', !!value) } + setDuration(duration) { + if (this.player.setDuration) { + setTimeout(() => this.player.setDuration(duration)) + } + } + get remainingTracks() { const index = this.queueGrouplike.items.indexOf(this.playingTrack) const length = this.queueGrouplike.items.length @@ -772,6 +778,13 @@ export default class Backend extends EventEmitter { }) } + queuePlayer.on('playing', track => { + if (track) { + const metadata = this.getMetadataFor(track) + queuePlayer.setDuration(metadata.duration) + } + }) + return queuePlayer } -- cgit 1.3.0-6-gf8a5