From f7009d9ab4aa4c140e9faa0190846b5b6ec8239a Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 29 May 2018 10:10:14 -0300 Subject: More functions --- index.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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)) -- cgit 1.3.0-6-gf8a5