« 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--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))