Add in missing return statements
Fixes several bugs relating to dupe callbacks on the same tag
This commit is contained in:
parent
abe3c9f8aa
commit
beacdf98e7
@ -22,6 +22,14 @@ var html = `
|
||||
<form method="post" class="pure-form">
|
||||
<input class="pure-button pure-button-primary" type="submit" name="uid" value="BADC0FFEE">
|
||||
</form>
|
||||
<div>
|
||||
<form method="post" class="pure-form" style="display: inline-block;">
|
||||
<input class="pure-button pure-button-primary" type="submit" name="uid" value="STOPSTOP">
|
||||
</form>
|
||||
<form method="post" class="pure-form" style="display: inline-block;">
|
||||
<input class="pure-button pure-button-primary" type="submit" name="uid" value="PAUSEPAUSE">
|
||||
</form>
|
||||
</div>
|
||||
<form method="post" class="pure-form">
|
||||
<input type="text" name="uid" value="0123456789"> <input class="pure-button pure-button-primary" type="submit">
|
||||
</form>
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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 => {
|
||||
|
@ -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;
|
||||
|
@ -43,3 +43,5 @@ module.exports = {
|
||||
, NotFoundTag: NotFoundTag
|
||||
, FileTag: FileTag
|
||||
};
|
||||
|
||||
// vim:ts=2 sw=2 et:
|
||||
|
@ -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');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user