🐛 Fix queue progress bar
This commit is contained in:
parent
1af218f340
commit
164a5cd5e5
1 changed files with 10 additions and 8 deletions
|
@ -1013,9 +1013,11 @@ class Player extends EventEmitter {
|
||||||
if (!queue) return
|
if (!queue) return
|
||||||
const timecodes = options && typeof options === 'object' ? options.timecodes : false
|
const timecodes = options && typeof options === 'object' ? options.timecodes : false
|
||||||
// Stream time of the dispatcher
|
// Stream time of the dispatcher
|
||||||
const currentStreamTime = options && options.queue ? queue.previousTracks.map((t) => t.durationMS).reduce((p, c) => p + c) + queue.currentStreamTime : queue.currentStreamTime
|
const previousTracksTime = queue.previousTracks.length > 0 ? queue.previousTracks.map((t) => t.durationMS) : 0
|
||||||
|
const currentStreamTime = options && options.queue ? previousTracksTime + queue.currentStreamTime : queue.currentStreamTime
|
||||||
// Total stream time
|
// Total stream time
|
||||||
const totalTime = options && options.queue ? queue.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : queue.playing.durationMS
|
const totalTracksTime = queue.tracks.length > 0 ? queue.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0
|
||||||
|
const totalTime = options && options.queue ? totalTracksTime : queue.playing.durationMS
|
||||||
// Stream progress
|
// Stream progress
|
||||||
const index = Math.round((currentStreamTime / totalTime) * 15)
|
const index = Math.round((currentStreamTime / totalTime) * 15)
|
||||||
// conditions
|
// conditions
|
||||||
|
@ -1023,17 +1025,17 @@ class Player extends EventEmitter {
|
||||||
const bar = '▬▬▬▬▬▬▬▬▬▬▬▬▬▬'.split('')
|
const bar = '▬▬▬▬▬▬▬▬▬▬▬▬▬▬'.split('')
|
||||||
bar.splice(index, 0, '🔘')
|
bar.splice(index, 0, '🔘')
|
||||||
if (timecodes) {
|
if (timecodes) {
|
||||||
const parsed = ms(currentStreamTime)
|
const currentTimecode = Util.buildTimecode(ms(currentStreamTime))
|
||||||
const currentTimecode = Util.buildTimecode(parsed)
|
const endTimecode = Util.buildTimecode(ms(totalTime))
|
||||||
return `${currentTimecode} ┃ ${bar.join('')} ┃ ${queue.playing.duration}`
|
return `${currentTimecode} ┃ ${bar.join('')} ┃ ${endTimecode}`
|
||||||
} else {
|
} else {
|
||||||
return `${bar.join('')}`
|
return `${bar.join('')}`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (timecodes) {
|
if (timecodes) {
|
||||||
const parsed = ms(currentStreamTime)
|
const currentTimecode = Util.buildTimecode(ms(currentStreamTime))
|
||||||
const currentTimecode = Util.buildTimecode(parsed)
|
const endTimecode = Util.buildTimecode(ms(totalTime))
|
||||||
return `${currentTimecode} ┃ 🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬ ┃ ${queue.playing.duration}`
|
return `${currentTimecode} ┃ 🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬ ┃ ${endTimecode}`
|
||||||
} else {
|
} else {
|
||||||
return '🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬'
|
return '🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue