diff options
-rw-r--r-- | backend.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/backend.js b/backend.js index b3e6564..7ee6873 100644 --- a/backend.js +++ b/backend.js @@ -446,8 +446,11 @@ class QueuePlayer extends EventEmitter { if (automaticallyQueueNextTrack) { const parent = track[parentSymbol] if (!parent) return false - const index = parent.items.indexOf(track) - const nextItem = parent.items[index + 1] + let index = parent.items.indexOf(track) + let nextItem + do { + nextItem = parent.items[++index] + } while (nextItem && !(isTrack(nextItem) || isGroup(nextItem))) if (!nextItem) return false this.queue(nextItem) queueIndex = queue.items.length - 1 @@ -472,8 +475,11 @@ class QueuePlayer extends EventEmitter { if (automaticallyQueuePreviousTrack) { const parent = track[parentSymbol] if (!parent) return false - const index = parent.items.indexOf(track) - const previousItem = parent.items[index - 1] + let index = parent.items.indexOf(track) + let previousItem + do { + previousItem = parent.items[--index] + } while (previousItem && !(isTrack(previousItem) || isGroup(previousItem))) if (!previousItem) return false this.queue(previousItem, 'FRONT') queueIndex = 0 |