« get me outta code hell

Stub some functions in InternalApp - 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:02:28 -0300
committerFlorrie <towerofnix@gmail.com>2018-05-29 10:02:28 -0300
commit9d3761a98590ec665bb221f2821a8d05e3fe97b8 (patch)
tree58a297ab725418fc00822f61fccf6c89e4f234ec
parent7c28e5c072ca27e6f2fc4a488c32718514aad924 (diff)
Stub some functions in InternalApp
-rw-r--r--index.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/index.js b/index.js
index a3b4b9f..b85e0e8 100644
--- a/index.js
+++ b/index.js
@@ -5,6 +5,19 @@ const { getDownloaderFor } = require('./downloaders')
 const EventEmitter = require('events')
 
 class InternalApp extends EventEmitter {
+  constructor() {
+    super()
+    this.player = null
+  }
+
+  async setup() {
+    this.player = await getPlayer()
+  }
+
+  async startPlaying(arg) {
+    this.player.playFile(await this.download(arg))
+  }
+
   download(arg) {
     return getDownloaderFor(arg)(arg)
   }
@@ -12,8 +25,8 @@ class InternalApp extends EventEmitter {
 
 async function main() {
   const internalApp = new InternalApp()
-  const player = await getPlayer()
-  player.playFile(await internalApp.download('http://billwurtz.com/cable-television.mp3'))
+  await internalApp.setup()
+  internalApp.startPlaying('http://billwurtz.com/cable-television.mp3')
 }
 
 main().catch(err => console.error(err))