🐛 Handle videos unavailable

This commit is contained in:
Androz2091 2021-02-20 16:03:55 +01:00
parent d79c39949d
commit 0c5223fea8

View file

@ -1094,14 +1094,6 @@ class Player extends EventEmitter {
})
}
newStream.on('error', (error) => {
if (error.message === 'Video unavailable') {
this.emit('error', 'VideoUnavailable', queue.firstMessage)
} else {
this.emit('error', error, queue.firstMessage)
}
})
setTimeout(() => {
if (queue.stream) queue.stream.destroy()
queue.stream = newStream
@ -1124,6 +1116,14 @@ class Player extends EventEmitter {
// Play the next track
return this._playTrack(queue, false)
})
newStream.on('error', (error) => {
if (error.message.includes('Video unavailable')) {
this.emit('error', 'VideoUnavailable', queue.firstMessage)
this._playTrack(queue, false)
} else {
this.emit('error', error, queue.firstMessage)
}
})
}, 1000)
})
}