From 9d3761a98590ec665bb221f2821a8d05e3fe97b8 Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 29 May 2018 10:02:28 -0300 Subject: Stub some functions in InternalApp --- index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'index.js') 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)) -- cgit 1.3.0-6-gf8a5