From 9162068126fffe4fa0d13d174cc3c14373fa2588 Mon Sep 17 00:00:00 2001 From: Florrie Date: Sat, 22 Dec 2018 23:23:06 -0400 Subject: Remove mpv player --- players.js | 89 -------------------------------------------------------------- 1 file changed, 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() } -- cgit 1.3.0-6-gf8a5