Addingm manual Event fireing, Universe as event property, and event when loading track
This commit is contained in:
51
lib/index.js
51
lib/index.js
@ -1,5 +1,6 @@
|
||||
//DATABASE
|
||||
"use strict";
|
||||
//DATABASE
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const low = require("lowdb");
|
||||
var db = low("db.json");
|
||||
const sid = require("short-id");
|
||||
@ -9,7 +10,8 @@ db.defaults({}).write();
|
||||
const httpp = require("http");
|
||||
var http = httpp.createServer();
|
||||
const io = require("socket.io");
|
||||
var ioClient = require("socket.io-client")("http://192.168.1.142:5000", { reconect: true });
|
||||
//var ioClient = require("socket.io-client")("http://192.168.1.142:5000", {reconnect:true});
|
||||
var ioClient = require("socket.io-client")("http://localhost:5000", { reconnect: true });
|
||||
ioClient.on("connect", () => {
|
||||
console.log("connected");
|
||||
});
|
||||
@ -105,13 +107,14 @@ class Timecode {
|
||||
else {
|
||||
this.startTime = new Date().getTime() - vlc.time;
|
||||
this.filePlaying = vlc.file;
|
||||
//console.log("vlc_update", vlc);
|
||||
}
|
||||
var d = vlc.time;
|
||||
this.toTrigger.forEach(e => {
|
||||
if (e.time.milliseconds <= d) {
|
||||
console.log("v", e);
|
||||
ios.emit("artnet", e.art);
|
||||
artnet.set(universe, Number(e.art.subnet), Number(e.art.value));
|
||||
artnet.set(e.art.universe, Number(e.art.subnet), Number(e.art.value));
|
||||
var i = this.toTrigger.indexOf(e);
|
||||
this.toTrigger.splice(i, 1);
|
||||
}
|
||||
@ -121,10 +124,10 @@ class Timecode {
|
||||
data.track = this.activeTrack.id;
|
||||
data.filePlaying = this.filePlaying;
|
||||
data.playing = this.playing;
|
||||
data.paused = vlc.paused;
|
||||
ios.emit("update", data);
|
||||
}
|
||||
update() {
|
||||
var d = new Date().getTime() - this.startTime;
|
||||
this.toTrigger.forEach(e => {
|
||||
if (e.time.milliseconds <= d) {
|
||||
console.log("u", e);
|
||||
@ -135,10 +138,18 @@ class Timecode {
|
||||
}
|
||||
});
|
||||
var data = {};
|
||||
var d;
|
||||
if (this.passedTime) {
|
||||
d = this.passedTime;
|
||||
}
|
||||
else {
|
||||
d = new Date().getTime() - this.startTime;
|
||||
}
|
||||
data.time = new FrameTime(d);
|
||||
data.track = this.activeTrack.id;
|
||||
data.filePlaying = this.filePlaying;
|
||||
data.playing = this.playing;
|
||||
data.paused = this.passedTime !== undefined ? true : false;
|
||||
ios.emit("update", data);
|
||||
}
|
||||
loadTrack(trackid) {
|
||||
@ -156,8 +167,22 @@ class Timecode {
|
||||
this.toTrigger = tr;
|
||||
this.filePlaying = track.file;
|
||||
this.startTime = 0;
|
||||
if (this.activeTrack.load) {
|
||||
artnet(this.activeTrack.load.universe, this.activeTrack.load.subnet, this.activeTrack.load.value);
|
||||
}
|
||||
}
|
||||
pause() {
|
||||
this.passedTime = new Date().getTime() - this.startTime;
|
||||
}
|
||||
play() {
|
||||
if (this.passedTime) {
|
||||
this.startTime = new Date().getTime() - this.passedTime;
|
||||
if (this.filePlaying) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
this.passedTime = undefined;
|
||||
}
|
||||
if (!this.activeTrack)
|
||||
return;
|
||||
if (this.filePlaying) {
|
||||
@ -222,6 +247,14 @@ ios.on("connection", socket => {
|
||||
}
|
||||
timecode.play();
|
||||
});
|
||||
socket.on("pause", () => {
|
||||
if (timecode.filePlaying) {
|
||||
ioClient.emit("pause");
|
||||
}
|
||||
else {
|
||||
timecode.pause();
|
||||
}
|
||||
});
|
||||
socket.on("stop", () => {
|
||||
timecode.stop();
|
||||
if (timecode.activeTrack)
|
||||
@ -262,6 +295,16 @@ ios.on("connection", socket => {
|
||||
db.get(data.track + ".triggers").remove({ id: data.id }).write();
|
||||
senddata();
|
||||
});
|
||||
socket.on("fire", (data) => {
|
||||
artnet.set(data.universe, data.subnet, data.value);
|
||||
});
|
||||
socket.on("load_event", (data) => {
|
||||
console.log(data);
|
||||
db.get(data.id).assign({
|
||||
load: data.art
|
||||
}).write();
|
||||
senddata();
|
||||
});
|
||||
});
|
||||
http.listen(5001);
|
||||
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user