From 0c5223fea8354e5a0209df4c6f3f332acf46c353 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sat, 20 Feb 2021 16:03:55 +0100 Subject: [PATCH] :bug: Handle videos unavailable --- src/Player.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Player.js b/src/Player.js index c9f8a41..419425e 100644 --- a/src/Player.js +++ b/src/Player.js @@ -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) }) }