diff options
author | Florrie <towerofnix@gmail.com> | 2018-12-22 23:23:06 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-12-22 23:23:06 -0400 |
commit | 9162068126fffe4fa0d13d174cc3c14373fa2588 (patch) | |
tree | 50c542073a7453a79067ada29e5e894f0bf7c3a6 | |
parent | dad157a7e36668b78d865d93c66e5a9fd324773d (diff) |
Remove mpv player
-rw-r--r-- | players.js | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/players.js b/players.js index dccdea2..9941ce5 100644 --- a/players.js +++ b/players.js @@ -1,9 +1,4 @@ -// stolen from http-music - -// const { spawn } = require('child_process') -// const FIFO = require('fifo-js') const EventEmitter = require('events') -const { commandExists, killProcess } = require('./general-util') function getTimeStrings({curHour, curMin, curSec, lenHour, lenMin, lenSec}) { // Multiplication casts to numbers; addition prioritizes strings. @@ -141,90 +136,6 @@ module.exports.WebPlayer = class extends Player { } } -module.exports.MPVPlayer = class extends Player { - getMPVOptions(file) { - return ['--no-video', file] - } - - playFile(file) { - // The more powerful MPV player. MPV is virtually impossible for a human - // being to install; if you're having trouble with it, try the SoX player. - - this.process = spawn('mpv', this.getMPVOptions(file)) - - this.process.stderr.on('data', data => { - if (this.disablePlaybackStatus) { - return - } - - const match = data.toString().match( - /(..):(..):(..) \/ (..):(..):(..) \(([0-9]+)%\)/ - ) - - if (match) { - const [ - curHour, curMin, curSec, // ##:##:## - lenHour, lenMin, lenSec, // ##:##:## - percent // ###% - ] = match.slice(1) - - this.printStatusLine(getTimeStrings({curHour, curMin, curSec, lenHour, lenMin, lenSec})) - } - }) - - return new Promise(resolve => { - this.process.once('close', resolve) - }) - } -} - -module.exports.ControllableMPVPlayer = class extends module.exports.MPVPlayer { - getMPVOptions(file) { - return ['--input-file=' + this.fifo.path, ...super.getMPVOptions(file)] - } - - playFile(file) { - this.fifo = new FIFO() - - return super.playFile(file) - } - - sendCommand(command) { - if (this.fifo) { - this.fifo.write(command) - } - } - - seekAhead(secs) { - this.sendCommand(`seek +${parseFloat(secs)}`) - } - - seekBack(secs) { - this.sendCommand(`seek -${parseFloat(secs)}`) - } - - volUp(amount) { - this.sendCommand(`add volume +${parseFloat(amount)}`) - } - - volDown(amount) { - this.sendCommand(`add volume -${parseFloat(amount)}`) - } - - togglePause() { - this.sendCommand('cycle pause') - } - - kill() { - if (this.fifo) { - this.fifo.close() - delete this.fifo - } - - return super.kill() - } -} - module.exports.getPlayer = async function() { return new module.exports.WebPlayer() } |