« get me outta code hell

(l) to loop currently playing track - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-01-24 17:09:25 -0400
committerFlorrie <towerofnix@gmail.com>2019-01-24 17:09:25 -0400
commitb4e575f4ec8b65464f9a8f109ddf3907cf30b853 (patch)
treeaa1c68ba24a8da7f07770464f8d2505c9102b822 /ui.js
parent3c04268c5e3ee34b6aaf3d7d6e21316741132ff0 (diff)
(l) to loop currently playing track
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/ui.js b/ui.js
index 00aa403..4a8f0a4 100644
--- a/ui.js
+++ b/ui.js
@@ -364,7 +364,7 @@ class AppElement extends FocusElement {
 
     this.player.on('printStatusLine', data => {
       if (this.playingTrack) {
-        this.playbackInfoElement.updateProgress(data)
+        this.playbackInfoElement.updateProgress(data, this.player)
       }
     })
 
@@ -407,6 +407,8 @@ class AppElement extends FocusElement {
       this.seekBack(10)
     } else if (telc.isSpace(keyBuf)) {
       this.togglePause()
+    } else if (telc.isCaselessLetter(keyBuf, 'l')) {
+      this.toggleLoop()
     } else if (telc.isEscape(keyBuf)) {
       this.clearPlayingTrack()
     } else if (telc.isShiftUp(keyBuf) || telc.isCaselessLetter(keyBuf, 'p')) {
@@ -497,6 +499,10 @@ class AppElement extends FocusElement {
     this.player.togglePause()
   }
 
+  toggleLoop() {
+    this.player.toggleLoop()
+  }
+
   stopPlaying() {
     // We emit this so playTrack doesn't immediately start a new track.
     // We aren't *actually* about to play a new track.
@@ -1652,9 +1658,12 @@ class PlaybackInfoElement extends DisplayElement {
     }
   }
 
-  updateProgress({timeDone, timeLeft, duration, lenSecTotal, curSecTotal}) {
+  updateProgress({timeDone, timeLeft, duration, lenSecTotal, curSecTotal}, player) {
     this.progressBarLabel.text = '-'.repeat(Math.floor(this.w / lenSecTotal * curSecTotal))
     this.progressTextLabel.text = timeDone + ' / ' + duration
+    if (player.isLooping) {
+      this.progressTextLabel.text += ' [Looping]'
+    }
     this.fixLayout()
   }