« 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--players.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/players.js b/players.js
index 0c980e7..98fff09 100644
--- a/players.js
+++ b/players.js
@@ -36,6 +36,8 @@ class Player extends EventEmitter {
   volDown(amount) {}
   togglePause() {}
   toggleLoop() {}
+  setPause() {}
+  setLoop() {}
 
   async kill() {
     if (this.process) {
@@ -147,6 +149,7 @@ module.exports.ControllableMPVPlayer = class extends module.exports.MPVPlayer {
   }
 
   togglePause() {
+    this.isPaused = !this.isPaused
     this.sendCommand('cycle pause')
   }
 
@@ -155,6 +158,16 @@ module.exports.ControllableMPVPlayer = class extends module.exports.MPVPlayer {
     this.sendCommand('cycle loop')
   }
 
+  setPause(val) {
+    this.isPaused = !!val
+    this.sendCommand('set pause ' + (val ? 'yes' : 'no'))
+  }
+
+  setLoop(val) {
+    this.isLooping = !!val
+    this.sendCommand('set loop ' + (val ? 'yes' : 'no'))
+  }
+
   kill() {
     if (this.fifo) {
       this.fifo.close()