« get me outta code hell

More 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>2018-05-29 10:10:14 -0300
committerFlorrie <towerofnix@gmail.com>2018-05-29 10:10:14 -0300
commitf7009d9ab4aa4c140e9faa0190846b5b6ec8239a (patch)
tree7dc467bc127715605a04debbdd83f3cd69ef7b7e
parent9d3761a98590ec665bb221f2821a8d05e3fe97b8 (diff)
More functions
-rw-r--r--index.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/index.js b/index.js
index b85e0e8..d064fb5 100644
--- a/index.js
+++ b/index.js
@@ -18,6 +18,22 @@ class InternalApp extends EventEmitter {
     this.player.playFile(await this.download(arg))
   }
 
+  stopPlaying() {
+    this.player.kill()
+  }
+
+  seekAhead(seconds) {
+    this.player.seekAhead(seconds)
+  }
+
+  seekBehind(seconds) {
+    this.player.seekBehind(seconds)
+  }
+
+  togglePause() {
+    this.player.togglePause()
+  }
+
   download(arg) {
     return getDownloaderFor(arg)(arg)
   }
@@ -26,7 +42,13 @@ class InternalApp extends EventEmitter {
 async function main() {
   const internalApp = new InternalApp()
   await internalApp.setup()
-  internalApp.startPlaying('http://billwurtz.com/cable-television.mp3')
+  await internalApp.startPlaying('http://billwurtz.com/cable-television.mp3')
+  await new Promise(r => setTimeout(r, 2000))
+  internalApp.togglePause()
+  await new Promise(r => setTimeout(r, 1000))
+  internalApp.togglePause()
+  await new Promise(r => setTimeout(r, 2000))
+  internalApp.stopPlaying()
 }
 
 main().catch(err => console.error(err))