diff options
Diffstat (limited to 'ui.js')
-rw-r--r-- | ui.js | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/ui.js b/ui.js index b0276c6..6965331 100644 --- a/ui.js +++ b/ui.js @@ -342,9 +342,9 @@ class AppElement extends FocusElement { } else if (telc.isEscape(keyBuf)) { this.clearPlayingTrack() } else if (telc.isShiftUp(keyBuf) || telc.isCaselessLetter(keyBuf, 'p')) { - this.playPreviousTrack(this.playingTrack) + this.playPreviousTrack(this.playingTrack, true) } else if (telc.isShiftDown(keyBuf) || telc.isCaselessLetter(keyBuf, 'n')) { - this.playNextTrack(this.playingTrack) + this.playNextTrack(this.playingTrack, true) } else if (telc.isCharacter(keyBuf, '1') && this.tabber.selectable) { this.root.select(this.tabber) } else if (telc.isCharacter(keyBuf, '2') && this.queueListingElement.selectable) { @@ -601,7 +601,7 @@ class AppElement extends FocusElement { } } - playNextTrack(track) { + playNextTrack(track, automaticallyQueueNextTrack = false) { if (!track) { return false } @@ -614,27 +614,28 @@ class AppElement extends FocusElement { queueIndex++ if (queueIndex >= queue.items.length) { - /* - const parent = track[parentSymbol] - if (!parent) { - return false - } - const index = parent.items.indexOf(track) - const nextItem = parent.items[index + 1] - if (!nextItem) { + if (automaticallyQueueNextTrack) { + const parent = track[parentSymbol] + if (!parent) { + return false + } + const index = parent.items.indexOf(track) + const nextItem = parent.items[index + 1] + if (!nextItem) { + return false + } + this.queueGrouplikeItem(nextItem, false) + queueIndex = queue.items.length - 1 + } else { return false } - this.queueGrouplikeItem(nextItem, false) - queueIndex = queue.items.length - 1 - */ - return false } this.playGrouplikeItem(queue.items[queueIndex], false) return true } - playPreviousTrack(track) { + playPreviousTrack(track, automaticallyQueuePreviousTrack = false) { if (!track) { return false } @@ -647,17 +648,21 @@ class AppElement extends FocusElement { queueIndex-- if (queueIndex < 0) { - const parent = track[parentSymbol] - if (!parent) { - return false - } - const index = parent.items.indexOf(track) - const previousItem = parent.items[index - 1] - if (!previousItem) { + if (automaticallyQueuePreviousTrack) { + const parent = track[parentSymbol] + if (!parent) { + return false + } + const index = parent.items.indexOf(track) + const previousItem = parent.items[index - 1] + if (!previousItem) { + return false + } + this.queueGrouplikeItem(previousItem, 'FRONT') + queueIndex = 0 + } else { return false } - this.queueGrouplikeItem(previousItem, false, 'FRONT') - queueIndex = 0 } this.playGrouplikeItem(queue.items[queueIndex], false) |