⚡ Improve stream time calculation
This commit is contained in:
parent
a0cdcbc461
commit
27e28ef41f
3 changed files with 10 additions and 10 deletions
|
@ -746,7 +746,7 @@ class Player {
|
|||
const queue = this.queues.find((g) => g.guildID === guildID)
|
||||
if (!queue) return
|
||||
// Stream time of the dispatcher
|
||||
const currentStreamTime = queue.voiceConnection.dispatcher.streamTime
|
||||
const currentStreamTime = queue.calculatedStreamTime
|
||||
// Total stream time
|
||||
const totalTime = queue.playing.durationMS
|
||||
// Stream progress
|
||||
|
@ -813,7 +813,7 @@ class Player {
|
|||
filter: 'audioonly',
|
||||
opusEncoded: true,
|
||||
encoderArgs,
|
||||
seek: currentStreamTime
|
||||
seek: currentStreamTime + queue.additionalStreamTime
|
||||
})
|
||||
setTimeout(() => {
|
||||
if (queue.stream) queue.stream.destroy()
|
||||
|
@ -823,7 +823,7 @@ class Player {
|
|||
bitrate: 'auto'
|
||||
})
|
||||
if (currentStreamTime) {
|
||||
queue.playing.streamTime += currentStreamTime
|
||||
queue.additionalStreamTime += currentStreamTime
|
||||
}
|
||||
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200)
|
||||
// When the track starts
|
||||
|
@ -832,8 +832,8 @@ class Player {
|
|||
})
|
||||
// When the track ends
|
||||
queue.voiceConnection.dispatcher.on('finish', () => {
|
||||
// reset streamTime
|
||||
if (queue.repeatMode) queue.playing.streamTime = 0
|
||||
// Reset streamTime
|
||||
queue.additionalStreamTime = 0
|
||||
// Play the next track
|
||||
return this._playTrack(queue.guildID, false)
|
||||
})
|
||||
|
|
|
@ -61,6 +61,11 @@ class Queue extends EventEmitter {
|
|||
* @type {Object}
|
||||
*/
|
||||
this.filters = {}
|
||||
/**
|
||||
* Additional stream time
|
||||
* @type {Number}
|
||||
*/
|
||||
this.additionalStreamTime = 0
|
||||
}
|
||||
|
||||
get calculatedVolume () {
|
||||
|
|
|
@ -56,11 +56,6 @@ class Track {
|
|||
* @type {Queue}
|
||||
*/
|
||||
this.queue = queue
|
||||
|
||||
/**
|
||||
* Stream time of the track (available on applying filters)
|
||||
*/
|
||||
this.streamTime = 0
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue