Add queue total time

Closes #293
This commit is contained in:
Androz2091 2021-02-26 15:03:25 +01:00
parent c594f48d0b
commit 2b439dc7cc
2 changed files with 5 additions and 1 deletions

View file

@ -1045,7 +1045,7 @@ class Player extends EventEmitter {
const previousTracksTime = queue.previousTracks.length > 0 ? queue.previousTracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0
const currentStreamTime = options && options.queue ? previousTracksTime + queue.currentStreamTime : queue.currentStreamTime
// Total stream time
const totalTracksTime = queue.tracks.length > 0 ? queue.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0
const totalTracksTime = queue.totalTime
const totalTime = options && options.queue ? previousTracksTime + totalTracksTime : queue.playing.durationMS
// Stream progress
const index = Math.round((currentStreamTime / totalTime) * 15)

View file

@ -98,6 +98,10 @@ class Queue extends EventEmitter {
return this.filters.bassboost ? this.volume + 50 : this.volume
}
get totalTime () {
return this.tracks.length > 0 ? this.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0
}
get currentStreamTime () {
return this.voiceConnection.dispatcher
? this.voiceConnection.dispatcher.streamTime + this.additionalStreamTime