pi-rfid-jukebox/jukebox/library/index.js
Annika Backstrom 232929a47a Update FileTag for multi-field
We are separating an identifier (uuid) from the human-readable label.
2019-12-15 12:14:55 -05:00

39 lines
759 B
JavaScript

"use strict";
const EventEmitter = require('events').EventEmitter;
const tags = require('./tags');
class Library extends EventEmitter {
constructor(config, backend) {
super();
this.config = config;
this.backend = backend;
}
find(tag) {
if (tag === this.config.stop_id) {
this.emit('action', new tags.StopCommand(tag));
return;
}
if (tag === this.config.pause_id) {
this.emit('action', new tags.PauseCommand(tag));
return;
}
this.backend.find(tag, track => {
if (!track) {
this.emit('action', new tags.NotFoundTag(tag));
return;
}
this.emit('action', new tags.FileTag(tag, track));
});
}
}
module.exports.Library = Library;
// vim:set ts=2 sw=2 et: