« get me outta code hell

Support isPaused, setPause/setLoop functions - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-05-28 18:56:05 -0300
committerFlorrie <towerofnix@gmail.com>2019-05-28 18:56:05 -0300
commit6f84b15e76591c4519927966c6fbcafd074ead8f (patch)
tree1b79e193ce5c2cbe72918d13ec18de6277c1e772
parent5698c5fd74951c14603e2e5b4ec51a32467c99f1 (diff)
Support isPaused, setPause/setLoop functions
-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()