diff --git a/.gitignore b/.gitignore index f5fc507..79783d1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,4 @@ node_modules lib .vagrant config.json - npm-debug.log - -media/* -!media/.do_not_delete diff --git a/config.json.sample b/config.json.sample index 89be3d3..88c4382 100644 --- a/config.json.sample +++ b/config.json.sample @@ -3,6 +3,13 @@ "tag_reader": ["./lib/bin/python", "./bin/tag-reader"], "mpg321": ["/usr/bin/mpg321", "-R", "-"], + "media_path": "/path/to/media", + + "play_throttle": 5000, + "pause_throttle": 2000, + "stop_throttle": 2000, + "unknown_throttle": 2000, + "stop_id": "abcdef1234", "pause_id": "567890abcd" } diff --git a/jukebox/library/file-backend.js b/jukebox/library/file-backend.js index 3af117a..bcf5459 100644 --- a/jukebox/library/file-backend.js +++ b/jukebox/library/file-backend.js @@ -1,7 +1,6 @@ "use strict"; const glob = require('glob'); -const basename = require('path').basename; class FileBackend { constructor(config) { @@ -9,9 +8,9 @@ class FileBackend { } find(tag, callback) { - glob('media/' + tag + ' - *.mp3', (err, files) => { + glob(this.config.media_path + '/' + tag + ' - *.mp3', (err, files) => { if (files.length > 0) { - return callback(basename(files[0])); + return callback(files[0]); } callback(); }); diff --git a/jukebox/library/tags.js b/jukebox/library/tags.js index bb9b6fe..767fddf 100644 --- a/jukebox/library/tags.js +++ b/jukebox/library/tags.js @@ -1,3 +1,5 @@ +const basename = require('path').basename; + class Tag { constructor(tag) { this.tag = tag; @@ -9,15 +11,15 @@ class Tag { } class StopCommand extends Tag { - toString() { - return "Command: STOP"; - } + toString() { + return "Command: STOP"; + } } class PauseCommand extends Tag { - toString() { - return "Command: PAUSE"; - } + toString() { + return "Command: PAUSE"; + } } class NotFoundTag extends Tag { @@ -33,15 +35,15 @@ class FileTag extends Tag { } toString() { - return this.path; + return basename(this.path); } } module.exports = { - StopCommand: StopCommand - , PauseCommand: PauseCommand - , NotFoundTag: NotFoundTag - , FileTag: FileTag + StopCommand: StopCommand + , PauseCommand: PauseCommand + , NotFoundTag: NotFoundTag + , FileTag: FileTag }; // vim:ts=2 sw=2 et: diff --git a/jukebox/media-player.js b/jukebox/media-player.js index e35e012..fcdb59b 100644 --- a/jukebox/media-player.js +++ b/jukebox/media-player.js @@ -15,6 +15,8 @@ class MediaPlayer extends ChildProcessEmitter { constructor(config, logger) { super(config.mpg321, logger); + this.config = config; + this.stderrFilters.push(line => { return line.substr(0, 3) == '@F ' }); @@ -50,7 +52,7 @@ class MediaPlayer extends ChildProcessEmitter { _playFile(tag) { this.emit('command', tag); - this.send("LOAD media/" + tag.path); + this.send("LOAD " + tag.path); } _unknown(tag) { diff --git a/media/.do_not_delete b/media/.do_not_delete deleted file mode 100644 index e69de29..0000000