diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-05-14 19:53:31 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-16 22:29:28 -0300 |
commit | 9a1d0c26338a7d0851c60b99296669cdc80673f2 (patch) | |
tree | 55f8a3c07c0591fde8397a863c170b976791a760 /backend.js | |
parent | 8baa393ea05ac894ab78f6ff163d876cee4934d5 (diff) |
new GhostPlayer class & support 👻
This also makes the UI not explode when duration strings aren't available for progress bar display, and shows getTimeStringsFromSec how to handle that.
Diffstat (limited to 'backend.js')
-rw-r--r-- | backend.js | 13 |
1 files changed, 13 insertions, 0 deletions
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 } |