diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-03-24 00:33:50 -0300 |
---|---|---|
committer | (quasar) nebula <towerofnix@gmail.com> | 2021-03-24 00:34:03 -0300 |
commit | fe603bc08f14d8fb86d1d832850ee8709f307f75 (patch) | |
tree | 9cdc2e20a95d8c2a55550e8d24061a95c4e55270 | |
parent | e6c0e708b6781473b6343a9d9aa111f215226298 (diff) |
[Looping] indicator when queue is looping
-rw-r--r-- | backend.js | 4 | ||||
-rw-r--r-- | ui.js | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/backend.js b/backend.js index 98d748b..ad13127 100644 --- a/backend.js +++ b/backend.js @@ -573,6 +573,7 @@ class QueuePlayer extends EventEmitter { setLoopQueueAtEnd(value) { this.loopQueueAtEnd = !!value + this.emit('set-loop-queue-at-end', !!value) } get remainingTracks() { @@ -667,7 +668,8 @@ class Backend extends EventEmitter { 'vol-up', 'vol-down', 'set-volume', - 'set-pause-next-track' + 'set-pause-next-track', + 'set-loop-queue-at-end' ]) { queuePlayer.on(event, (...data) => { this.emit(event, queuePlayer, ...data) diff --git a/ui.js b/ui.js index de73a81..a167dab 100644 --- a/ui.js +++ b/ui.js @@ -435,7 +435,8 @@ class AppElement extends FocusElement { 'handleProcessMetadataProgress', 'handleQueueUpdated', 'handleAddedQueuePlayer', - 'handleRemovedQueuePlayer' + 'handleRemovedQueuePlayer', + 'handleSetLoopQueueAtEnd' ]) { this[key] = this[key].bind(this) } @@ -506,12 +507,14 @@ class AppElement extends FocusElement { this.backend.on('processMetadata progress', this.handleProcessMetadataProgress) this.backend.on('added queue player', this.handleAddedQueuePlayer) this.backend.on('removed queue player', this.handleRemovedQueuePlayer) + this.backend.on('set-loop-queue-at-end', this.handleSetLoopQueueAtEnd) } removeBackendListeners() { this.backend.removeListener('processMetadata progress', this.handleProcessMetadataProgress) this.backend.removeListener('added queue player', this.handleAddedQueuePlayer) this.backend.removeListener('removed queue player', this.handleRemovedQueuePlayer) + this.backend.removeListener('set-loop-queue-at-end', this.handleSetLoopQueueAtEnd) } handleAddedQueuePlayer(queuePlayer) { @@ -525,6 +528,10 @@ class AppElement extends FocusElement { } } + handleSetLoopQueueAtEnd() { + this.updateQueueLengthLabel() + } + async handlePlaying(track, oldTrack, queuePlayer) { const PIE = this.getPlaybackInfoElementForQueuePlayer(queuePlayer) if (PIE) { @@ -1725,13 +1732,16 @@ class AppElement extends FocusElement { const { duration: durationString } = getTimeStringsFromSec(0, durationTotal) this.queueTimeLabel.text = `(${durationSymbol + durationString + approxSymbol})` + let collapseExtraInfo = false if (playingTrack) { let insertString const distance = Math.abs(selectedIndex - playingIndex) if (selectedIndex < playingIndex) { insertString = ` (-${distance})` + collapseExtraInfo = true } else if (selectedIndex > playingIndex) { insertString = ` (+${distance})` + collapseExtraInfo = true } else { insertString = '' } @@ -1740,6 +1750,10 @@ class AppElement extends FocusElement { this.queueLengthLabel.text = `(${items.length})` } + if (this.SQP.loopQueueAtEnd) { + this.queueLengthLabel.text += (collapseExtraInfo ? ` [L${unic.ELLIPSIS}]` : ` [Looping]`) + } + // Layout stuff to position the length and time labels correctly. this.queueLengthLabel.centerInParent() this.queueTimeLabel.centerInParent() |