diff --git a/bin/tag-reader-dummy b/bin/tag-reader-dummy
index 6acd3c7..3462cb8 100755
--- a/bin/tag-reader-dummy
+++ b/bin/tag-reader-dummy
@@ -22,6 +22,14 @@ var html = `
+
+
+
+
diff --git a/jukebox/library/file-backend.js b/jukebox/library/file-backend.js
index fb32d97..3af117a 100644
--- a/jukebox/library/file-backend.js
+++ b/jukebox/library/file-backend.js
@@ -11,7 +11,7 @@ class FileBackend {
find(tag, callback) {
glob('media/' + tag + ' - *.mp3', (err, files) => {
if (files.length > 0) {
- callback(basename(files[0]));
+ return callback(basename(files[0]));
}
callback();
});
diff --git a/jukebox/library/index.js b/jukebox/library/index.js
index 1bd2484..7c6dfd9 100644
--- a/jukebox/library/index.js
+++ b/jukebox/library/index.js
@@ -13,11 +13,13 @@ class Library extends EventEmitter {
find(tag) {
if (tag === this.config.stop_id) {
- this.emit('action', new tags.StopCommand());
+ this.emit('action', new tags.StopCommand(tag));
+ return;
}
if (tag === this.config.pause_id) {
- this.emit('action', new tags.PauseCommand());
+ this.emit('action', new tags.PauseCommand(tag));
+ return;
}
this.backend.find(tag, path => {
diff --git a/jukebox/library/play-log.js b/jukebox/library/play-log.js
index 5d406cf..eae589c 100644
--- a/jukebox/library/play-log.js
+++ b/jukebox/library/play-log.js
@@ -15,6 +15,8 @@ module.exports.PlayLog = class PlayLog extends EventEmitter {
updateLog(tag) {
this.last_tag = tag;
+ // early exit for NotFoundTag, these don't show
+ // up in the play history
if (tag instanceof tags.NotFoundTag) {
this.emit('update', tag);
return;
diff --git a/jukebox/library/tags.js b/jukebox/library/tags.js
index 0e62455..bb9b6fe 100644
--- a/jukebox/library/tags.js
+++ b/jukebox/library/tags.js
@@ -43,3 +43,5 @@ module.exports = {
, NotFoundTag: NotFoundTag
, FileTag: FileTag
};
+
+// vim:ts=2 sw=2 et:
diff --git a/jukebox/media-player.js b/jukebox/media-player.js
index 53db6a6..ce7f28e 100644
--- a/jukebox/media-player.js
+++ b/jukebox/media-player.js
@@ -6,6 +6,7 @@ const throttle = require('throttle-debounce/throttle');
const ChildProcessEmitter = require('./child-process').ChildProcessEmitter;
+const DEFAULT_STOP_THROTTLE = 2000;
const DEFAULT_PAUSE_THROTTLE = 2000;
const DEFAULT_PLAY_THROTTLE = 5000;
const DEFAULT_UNKNOWN_THROTTLE = 2000;
@@ -18,27 +19,26 @@ class MediaPlayer extends ChildProcessEmitter {
return line.substr(0, 3) == '@F '
});
- this.pauseThrottled = throttle(config.pause_throttle || DEFAULT_PAUSE_THROTTLE, () => {
- this._pause();
- });
-
- this.playFileThrottled = throttle(config.play_throttle || DEFAULT_PLAY_THROTTLE, (path) => {
- this._playFile(path);
- });
+ this.stopThrottled = throttle(config.stop_throttle || DEFAULT_STOP_THROTTLE, this._stop);
+ this.pauseThrottled = throttle(config.pause_throttle || DEFAULT_PAUSE_THROTTLE, this._pause);
+ this.playFileThrottled = throttle(config.play_throttle || DEFAULT_PLAY_THROTTLE, this._playFile);
+ // always throttled
this.unknown = throttle(config.unknown_throttle || DEFAULT_UNKNOWN_THROTTLE, this._unknown);
// default to unthrottled
- this.pause = this._pauseFile;
+ this.pause = this._pause;
this.playFile = this._playFile;
+ this.stop = this._stop;
}
throttle() {
+ this.stop = this.stopThrottled;
this.pause = this.pauseThrottled;
this.playFile = this.playFileThrottled;
}
- stop(tag) {
+ _stop(tag) {
this.emit('command', tag);
this.send('STOP');
}