Fix media player not running in media dir

This commit is contained in:
Annika Backstrom 2019-12-17 12:38:55 -05:00
parent 88fc77f0a5
commit 087a06a20c
2 changed files with 7 additions and 3 deletions

View File

@ -7,7 +7,7 @@ const { spawn } = require('child_process');
const { EventEmitter } = require('events'); const { EventEmitter } = require('events');
module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmitter { module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmitter {
constructor(command, logger) { constructor(command, logger, cwd) {
super(); super();
var emitter = this; var emitter = this;
@ -17,10 +17,14 @@ module.exports.ChildProcessEmitter = class ChildProcessEmitter extends EventEmit
this.logger = logger; this.logger = logger;
this.stderrFilters = []; this.stderrFilters = [];
var options = {
cwd: cwd,
};
var cmd = command[0], var cmd = command[0],
args = command.slice(1); args = command.slice(1);
this.childProcess = spawn(cmd, args); this.childProcess = spawn(cmd, args, options);
this.childProcess.on('error', function(err) { this.childProcess.on('error', function(err) {
emitter.logger.error("process error", { class: emitter.constructor.name, err: String(err).trim() }); emitter.logger.error("process error", { class: emitter.constructor.name, err: String(err).trim() });

View File

@ -13,7 +13,7 @@ const DEFAULT_UNKNOWN_THROTTLE = 2000;
class MediaPlayer extends ChildProcessEmitter { class MediaPlayer extends ChildProcessEmitter {
constructor(config, logger) { constructor(config, logger) {
super(config.mpg321, logger); super(config.mpg321, logger, config.media_path);
this.config = config; this.config = config;