« get me outta code hell

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:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 4a8f0a4..67f1bf4 100644
--- a/ui.js
+++ b/ui.js
@@ -409,6 +409,10 @@ class AppElement extends FocusElement {
       this.togglePause()
     } else if (telc.isCaselessLetter(keyBuf, 'l')) {
       this.toggleLoop()
+    } else if (telc.isCharacter(keyBuf, 'v')) {
+      this.volUp()
+    } else if (telc.isCharacter(keyBuf, 'V')) {
+      this.volDown()
     } else if (telc.isEscape(keyBuf)) {
       this.clearPlayingTrack()
     } else if (telc.isShiftUp(keyBuf) || telc.isCaselessLetter(keyBuf, 'p')) {
@@ -503,6 +507,14 @@ class AppElement extends FocusElement {
     this.player.toggleLoop()
   }
 
+  volUp(amount = 10) {
+    this.player.volUp(amount)
+  }
+
+  volDown(amount = 10) {
+    this.player.volDown(amount)
+  }
+
   stopPlaying() {
     // We emit this so playTrack doesn't immediately start a new track.
     // We aren't *actually* about to play a new track.
@@ -1664,6 +1676,9 @@ class PlaybackInfoElement extends DisplayElement {
     if (player.isLooping) {
       this.progressTextLabel.text += ' [Looping]'
     }
+    if (player.volume !== 100) {
+      this.progressTextLabel.text += ` [Volume: ${Math.round(player.volume)}%]`
+    }
     this.fixLayout()
   }