« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ui.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 1a64253..775dbcc 100644
--- a/ui.js
+++ b/ui.js
@@ -70,6 +70,10 @@ class AppElement extends FocusElement {
     this.playbackInfoElement = new PlaybackInfoElement()
     this.playbackPane.addChild(this.playbackInfoElement)
 
+    this.playbackInfoElement.on('seek back', () => this.seekBack(5))
+    this.playbackInfoElement.on('seek ahead', () => this.seekAhead(5))
+    this.playbackInfoElement.on('toggle pause', () => this.togglePause())
+
     // Dialogs
 
     this.openPlaylistDialog = new OpenPlaylistDialog()
@@ -1330,6 +1334,16 @@ class PlaybackInfoElement extends DisplayElement {
     centerX(this.downloadLabel)
   }
 
+  clicked(button) {
+    if (button === 'scroll-up') {
+      this.emit('seek back')
+    } else if (button === 'scroll-down') {
+      this.emit('seek ahead')
+    } else if (button === 'left') {
+      this.emit('toggle pause')
+    }
+  }
+
   updateProgress({timeDone, timeLeft, duration, lenSecTotal, curSecTotal}) {
     this.progressBarLabel.text = '-'.repeat(Math.floor(this.w / lenSecTotal * curSecTotal))
     this.progressTextLabel.text = timeDone + ' / ' + duration