diff options
author | liam4 <towerofnix@gmail.com> | 2017-06-26 23:24:02 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-06-26 23:24:02 -0300 |
commit | 811997668969a5bf782f9edc6fba92db7aa35b6d (patch) | |
tree | c7383084c60ff5197a4e2e3899ea92f6e8998baf /src/loop-play.js | |
parent | 0fcec41cd757adcd3c7f2f4c80b33141bb0a9bee (diff) |
Clean-up and such
Diffstat (limited to 'src/loop-play.js')
-rw-r--r-- | src/loop-play.js | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/src/loop-play.js b/src/loop-play.js index 3c00ef5..10b1d5f 100644 --- a/src/loop-play.js +++ b/src/loop-play.js @@ -1,13 +1,7 @@ 'use strict' const { spawn } = require('child_process') -const promisifyProcess = require('./promisify-process') -const sanitize = require('sanitize-filename') -const tempy = require('tempy') -const path = require('path') - const FIFO = require('fifo-js') - const EventEmitter = require('events') class PlayController { @@ -84,7 +78,7 @@ class PlayController { } skipCurrent() { - this.killProcess() + this.kill() } seekAhead(secs) { @@ -113,7 +107,7 @@ class PlayController { } } - killProcess() { + kill() { if (this.process) { this.process.kill() } @@ -125,13 +119,20 @@ class PlayController { this.currentTrack = null } + + logTrackInfo() { + if (this.currentTrack) { + const [ curTitle, curArg ] = this.currentTrack + console.log(`Playing: \x1b[1m${curTitle} \x1b[2m${curArg}\x1b[0m`) + } else { + console.log("No song currently playing.") + } + } } module.exports = function loopPlay(picker, playArgs = []) { - // Looping play function. Takes one argument, the "pick" function, - // which returns a track to play. Preemptively downloads the next - // track while the current one is playing for seamless continuation - // from one song to the next. Stops when the result of the pick + // Looping play function. Takes one argument, the "picker" function, + // which returns a track to play. Stops when the result of the picker // function is null (or similar). Optionally takes a second argument // used as arguments to the `play` process (before the file name). @@ -142,25 +143,6 @@ module.exports = function loopPlay(picker, playArgs = []) { return { promise, - - seekBack: secs => playController.seekBack(secs), - seekAhead: secs => playController.seekAhead(secs), - skipCurrent: () => playController.skipCurrent(), - volUp: amount => playController.volUp(amount), - volDown: amount => playController.volDown(amount), - togglePause: () => playController.togglePause(), - - kill: function() { - playController.killProcess() - }, - - logTrackInfo: function() { - if (playController.currentTrack) { - const [ curTitle, curArg ] = playController.currentTrack - console.log(`Playing: \x1b[1m${curTitle} \x1b[2m${curArg}\x1b[0m`) - } else { - console.log("No song currently playing.") - } - } + controller: playController } } |