removing small bugs
This commit is contained in:
parent
7c3f26a9f8
commit
9a60e5ee8d
439
lib/timec.js
439
lib/timec.js
@ -1,211 +1,230 @@
|
|||||||
"use strict";
|
//DATABASE
|
||||||
//DATABASE
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
const low = require("lowdb");
|
||||||
const low = require("lowdb");
|
var db = low("db.json");
|
||||||
var db = low("db.json");
|
const sid = require("short-id");
|
||||||
const sid = require("short-id");
|
sid.configure({ length: 12 });
|
||||||
sid.configure({ length: 12 });
|
db.defaults({}).write();
|
||||||
db.defaults({}).write();
|
//SOCKETIO
|
||||||
//SOCKETIO
|
const httpp = require("http");
|
||||||
const httpp = require("http");
|
var http = httpp.createServer();
|
||||||
var http = httpp.createServer();
|
const io = require("socket.io");
|
||||||
const io = require("socket.io");
|
var ioClient = require("socket.io-client")("http://192.168.1.22:5000", { reconect: true });
|
||||||
var ioClient = require("socket.io-client")("http://localhost:5000");
|
ioClient.on("connect", () => {
|
||||||
var ios = io(http);
|
console.log("connected");
|
||||||
const artnetp = require("artnet");
|
});
|
||||||
const universe = 21;
|
var ios = io(http);
|
||||||
var artnet = artnetp({ host: "192.168.1.255" });
|
const artnetp = require("artnet");
|
||||||
class FrameTime {
|
const universe = 21;
|
||||||
constructor(millis) {
|
var artnet = artnetp({ host: "192.168.1.255" });
|
||||||
this.lframe = 0;
|
class FrameTime {
|
||||||
this.lseconds = 0;
|
constructor(millis) {
|
||||||
this.lminutes = 0;
|
this.lframe = 0;
|
||||||
this.lhours = 0;
|
this.lseconds = 0;
|
||||||
this.lmilliseconds = 0;
|
this.lminutes = 0;
|
||||||
if (Number.isInteger(millis)) {
|
this.lhours = 0;
|
||||||
this.milliseconds = millis;
|
this.lmilliseconds = 0;
|
||||||
}
|
if (Number.isInteger(millis)) {
|
||||||
else if (typeof millis === "object") {
|
this.milliseconds = millis;
|
||||||
if (Number.isInteger(Number(millis.frame)) && Number.isInteger(Number(millis.seconds)) && Number.isInteger(Number(millis.minutes)) && Number.isInteger(Number(millis.hours))) {
|
}
|
||||||
this.lframe = millis.frame; //use the local, because its mor performant
|
else if (typeof millis === "object") {
|
||||||
this.lseconds = millis.seconds;
|
if (Number.isInteger(Number(millis.frame)) && Number.isInteger(Number(millis.seconds)) && Number.isInteger(Number(millis.minutes)) && Number.isInteger(Number(millis.hours))) {
|
||||||
this.lminutes = millis.minutes;
|
this.lframe = millis.frame; //use the local, because its mor performant
|
||||||
this.lhours = millis.hours;
|
this.lseconds = millis.seconds;
|
||||||
this.calcMillis();
|
this.lminutes = millis.minutes;
|
||||||
}
|
this.lhours = millis.hours;
|
||||||
else if (Number.isInteger(millis.milliseconds)) {
|
this.calcMillis();
|
||||||
this.milliseconds = millis.milliseconds;
|
}
|
||||||
}
|
else if (Number.isInteger(millis.milliseconds)) {
|
||||||
}
|
this.milliseconds = millis.milliseconds;
|
||||||
}
|
}
|
||||||
get milliseconds() {
|
}
|
||||||
return this.lmilliseconds;
|
}
|
||||||
}
|
get milliseconds() {
|
||||||
set milliseconds(val) {
|
return this.lmilliseconds;
|
||||||
this.lmilliseconds = val;
|
}
|
||||||
this.millisToFrame();
|
set milliseconds(val) {
|
||||||
}
|
this.lmilliseconds = val;
|
||||||
get frame() {
|
this.millisToFrame();
|
||||||
return this.lframe;
|
}
|
||||||
}
|
get frame() {
|
||||||
set frame(val) {
|
return this.lframe;
|
||||||
this.lframe = val;
|
}
|
||||||
this.calcMillis();
|
set frame(val) {
|
||||||
}
|
this.lframe = val;
|
||||||
get seconds() {
|
this.calcMillis();
|
||||||
return this.lseconds;
|
}
|
||||||
}
|
get seconds() {
|
||||||
set seconds(val) {
|
return this.lseconds;
|
||||||
this.lseconds = val;
|
}
|
||||||
this.calcMillis();
|
set seconds(val) {
|
||||||
}
|
this.lseconds = val;
|
||||||
get minutes() {
|
this.calcMillis();
|
||||||
return this.lminutes;
|
}
|
||||||
}
|
get minutes() {
|
||||||
set minutes(val) {
|
return this.lminutes;
|
||||||
this.lminutes = val;
|
}
|
||||||
this.calcMillis();
|
set minutes(val) {
|
||||||
}
|
this.lminutes = val;
|
||||||
get hours() {
|
this.calcMillis();
|
||||||
return this.lhours;
|
}
|
||||||
}
|
get hours() {
|
||||||
set hours(val) {
|
return this.lhours;
|
||||||
this.lhours = val;
|
}
|
||||||
this.calcMillis();
|
set hours(val) {
|
||||||
}
|
this.lhours = val;
|
||||||
calcMillis() {
|
this.calcMillis();
|
||||||
this.lmilliseconds = (this.frame / 25 * 1000) + this.seconds * 1000 + this.minutes * 60 * 1000 + this.hours * 60 * 60 * 1000;
|
}
|
||||||
}
|
calcMillis() {
|
||||||
millisToFrame() {
|
this.lmilliseconds = (this.frame / 25 * 1000) + this.seconds * 1000 + this.minutes * 60 * 1000 + this.hours * 60 * 60 * 1000;
|
||||||
var millis = this.lmilliseconds;
|
}
|
||||||
this.frame = Math.floor((millis % 1000) * 25 / 1000);
|
millisToFrame() {
|
||||||
this.seconds = Math.floor((millis / 1000) % 60);
|
var millis = this.lmilliseconds;
|
||||||
this.minutes = Math.floor((millis / (1000 * 60)) % 60);
|
this.frame = Math.floor((millis % 1000) * 25 / 1000);
|
||||||
this.hours = Math.floor((millis / (1000 * 60 * 60)) % 24);
|
this.seconds = Math.floor((millis / 1000) % 60);
|
||||||
}
|
this.minutes = Math.floor((millis / (1000 * 60)) % 60);
|
||||||
}
|
this.hours = Math.floor((millis / (1000 * 60 * 60)) % 24);
|
||||||
class Timecode {
|
}
|
||||||
vlcUpdate(vlc) {
|
}
|
||||||
this.startTime = new Date().getTime() - vlc.time;
|
class Timecode {
|
||||||
this.filePlaying = vlc.file;
|
vlcUpdate(vlc) {
|
||||||
}
|
if (!vlc.is_playing) {
|
||||||
update(time) {
|
this.stop();
|
||||||
var d = new Date().getTime() - this.startTime;
|
}
|
||||||
this.toTrigger.forEach(e => {
|
else {
|
||||||
if (e.time.milliseconds <= d) {
|
this.startTime = new Date().getTime() - vlc.time;
|
||||||
console.log(e);
|
this.filePlaying = vlc.file;
|
||||||
ios.emit("artnet", e.art);
|
console.log("vlc_update", vlc);
|
||||||
artnet.set(universe, e.art.subnet);
|
}
|
||||||
var i = this.toTrigger.indexOf(e);
|
}
|
||||||
this.toTrigger.splice(i, 1);
|
update(time) {
|
||||||
}
|
var d = new Date().getTime() - this.startTime;
|
||||||
});
|
this.toTrigger.forEach(e => {
|
||||||
var data = {};
|
if (e.time.milliseconds <= d) {
|
||||||
data.time = new FrameTime(d);
|
console.log(e);
|
||||||
data.track = this.activeTrack.id;
|
ios.emit("artnet", e.art);
|
||||||
ios.emit("update", data);
|
artnet.set(universe, e.art.subnet);
|
||||||
}
|
var i = this.toTrigger.indexOf(e);
|
||||||
loadTrack(trackid) {
|
this.toTrigger.splice(i, 1);
|
||||||
this.playing = false;
|
}
|
||||||
var track = db.get(trackid).value();
|
});
|
||||||
var tr = [];
|
var data = {};
|
||||||
track.triggers.forEach(t => {
|
data.time = new FrameTime(d);
|
||||||
var te = new TrackEvent();
|
data.track = this.activeTrack.id;
|
||||||
te.art = t.art;
|
data.filePlaying = this.filePlaying;
|
||||||
te.id = t.id;
|
ios.emit("update", data);
|
||||||
te.time = new FrameTime(t.time);
|
}
|
||||||
tr.push(te);
|
loadTrack(trackid) {
|
||||||
});
|
this.playing = false;
|
||||||
this.activeTrack = track;
|
var track = db.get(trackid).value();
|
||||||
this.toTrigger = tr;
|
var tr = [];
|
||||||
this.filePlaying = track.file;
|
track.triggers.forEach(t => {
|
||||||
this.startTime = 0;
|
var te = new TrackEvent();
|
||||||
}
|
te.art = t.art;
|
||||||
play() {
|
te.id = t.id;
|
||||||
if (this.filePlaying) {
|
te.time = new FrameTime(t.time);
|
||||||
ioClient.emit("play", { file: this.filePlaying });
|
tr.push(te);
|
||||||
ioClient.on("playing", () => {
|
});
|
||||||
this.startTime = new Date().getTime();
|
this.activeTrack = track;
|
||||||
});
|
this.toTrigger = tr;
|
||||||
ioClient.on("update", (data) => {
|
this.filePlaying = track.file;
|
||||||
this.vlcUpdate(data);
|
this.startTime = 0;
|
||||||
});
|
}
|
||||||
}
|
play() {
|
||||||
else {
|
if (!this.activeTrack)
|
||||||
this.startTime = new Date().getTime();
|
return;
|
||||||
this.playing = true;
|
if (this.filePlaying) {
|
||||||
}
|
ioClient.emit("play", { file: this.filePlaying });
|
||||||
this.interval = setInterval(this.update.bind(this), 1000 / 25);
|
ioClient.on("playing", () => {
|
||||||
}
|
this.startTime = new Date().getTime();
|
||||||
stop() {
|
});
|
||||||
clearInterval(this.interval);
|
ioClient.on("update", (data) => {
|
||||||
this.playing = false;
|
this.vlcUpdate(data);
|
||||||
if (this.filePlaying) {
|
});
|
||||||
ioClient.emit("stop");
|
}
|
||||||
ios.emit("stopped");
|
else {
|
||||||
}
|
this.startTime = new Date().getTime();
|
||||||
this.startTime = 0;
|
this.playing = true;
|
||||||
}
|
}
|
||||||
}
|
this.interval = setInterval(this.update.bind(this), 1000 / 25);
|
||||||
class TrackEvent {
|
}
|
||||||
}
|
stop() {
|
||||||
class Track {
|
clearInterval(this.interval);
|
||||||
}
|
this.playing = false;
|
||||||
var timecode = new Timecode();
|
if (this.filePlaying) {
|
||||||
ios.on("connection", socket => {
|
ioClient.emit("stop");
|
||||||
function senddata() {
|
ios.emit("stopped");
|
||||||
ios.emit("get_data", {
|
}
|
||||||
tracks: db.getState(),
|
this.startTime = 0;
|
||||||
loaded: timecode.activeTrack
|
}
|
||||||
});
|
}
|
||||||
}
|
class TrackEvent {
|
||||||
console.log("Client", socket.id, "connected");
|
}
|
||||||
socket.on("load", (id) => {
|
class Track {
|
||||||
var track = db.get(id).value();
|
}
|
||||||
if (track === undefined) {
|
var timecode = new Timecode();
|
||||||
return socket.emit("play_error", "Track doesn't exist");
|
ios.on("connection", socket => {
|
||||||
}
|
senddata();
|
||||||
timecode.loadTrack(id);
|
function senddata() {
|
||||||
senddata();
|
ios.emit("get_data", {
|
||||||
});
|
tracks: db.getState(),
|
||||||
socket.on("play", () => {
|
loaded: timecode.activeTrack
|
||||||
if (timecode.playing) {
|
});
|
||||||
return socket.emit("play_error", "the active track must be stoppen before re-plaing it");
|
}
|
||||||
}
|
console.log("Client", socket.id, "connected");
|
||||||
timecode.play();
|
socket.on("load", (id) => {
|
||||||
});
|
var track = db.get(id).value();
|
||||||
socket.on("stop", () => {
|
if (track === undefined) {
|
||||||
timecode.stop();
|
return socket.emit("play_error", "Track doesn't exist");
|
||||||
timecode.loadTrack(timecode.activeTrack.id);
|
}
|
||||||
});
|
timecode.loadTrack(id);
|
||||||
socket.on("create", (data) => {
|
senddata();
|
||||||
var track = new Track();
|
});
|
||||||
track.displayName = data.name;
|
socket.on("play", () => {
|
||||||
track.file = data.file;
|
if (timecode.playing) {
|
||||||
track.id = sid.generate();
|
return socket.emit("play_error", "the active track must be stoppen before re-plaing it");
|
||||||
track.triggers = [];
|
}
|
||||||
db.set(track.id, track).write();
|
timecode.play();
|
||||||
socket.emit("created", track);
|
});
|
||||||
senddata();
|
socket.on("stop", () => {
|
||||||
});
|
timecode.stop();
|
||||||
socket.on("set", (data) => {
|
timecode.loadTrack(timecode.activeTrack.id);
|
||||||
var tid = data.track;
|
});
|
||||||
var time = new FrameTime(data.time);
|
socket.on("create", (data) => {
|
||||||
var tracke = new TrackEvent();
|
var track = new Track();
|
||||||
tracke.art = data.art;
|
track.displayName = data.name;
|
||||||
tracke.time = time;
|
track.file = data.file;
|
||||||
tracke.id = sid.generate();
|
track.id = sid.generate();
|
||||||
db.get(tid + ".triggers").push(tracke).write();
|
track.triggers = [];
|
||||||
socket.emit("set_finished", tracke);
|
db.set(track.id, track).write();
|
||||||
senddata();
|
socket.emit("created", track);
|
||||||
});
|
senddata();
|
||||||
socket.on("get", () => {
|
});
|
||||||
senddata();
|
socket.on("set", (data) => {
|
||||||
});
|
var tid = data.track;
|
||||||
socket.on("delete", (data) => {
|
var time = new FrameTime(data.time);
|
||||||
db.get(data.track + ".triggers").remove({ id: data.id }).write();
|
if (data.id && data.id != "") {
|
||||||
senddata();
|
var tracke = db.get(tid + ".triggers").find({ id: data.id }).assign({
|
||||||
});
|
art: data.art,
|
||||||
});
|
time: time,
|
||||||
http.listen(5001);
|
}).write();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var tracke = new TrackEvent();
|
||||||
|
tracke.art = data.art;
|
||||||
|
tracke.time = time;
|
||||||
|
tracke.id = sid.generate();
|
||||||
|
db.get(tid + ".triggers").push(tracke).write();
|
||||||
|
}
|
||||||
|
senddata();
|
||||||
|
});
|
||||||
|
socket.on("get", () => {
|
||||||
|
senddata();
|
||||||
|
});
|
||||||
|
socket.on("delete", (data) => {
|
||||||
|
db.get(data.track + ".triggers").remove({ id: data.id }).write();
|
||||||
|
senddata();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
http.listen(5001);
|
||||||
//# sourceMappingURL=timec.js.map
|
//# sourceMappingURL=timec.js.map
|
File diff suppressed because one or more lines are too long
18
src/timec.ts
18
src/timec.ts
@ -10,9 +10,11 @@ db.defaults({}).write();
|
|||||||
import * as httpp from "http";
|
import * as httpp from "http";
|
||||||
var http = httpp.createServer();
|
var http = httpp.createServer();
|
||||||
import io = require("socket.io");
|
import io = require("socket.io");
|
||||||
var ioClient = require("socket.io-client")("192.168.1.22:5000");
|
var ioClient = require("socket.io-client")("http://192.168.1.22:5000", {reconect:true});
|
||||||
|
ioClient.on("connect", ()=>{
|
||||||
|
console.log("connected");
|
||||||
|
})
|
||||||
var ios = io(http);
|
var ios = io(http);
|
||||||
|
|
||||||
const artnetp = require("artnet");
|
const artnetp = require("artnet");
|
||||||
const universe = 21;
|
const universe = 21;
|
||||||
var artnet = artnetp({host:"192.168.1.255"});
|
var artnet = artnetp({host:"192.168.1.255"});
|
||||||
@ -107,8 +109,13 @@ class Timecode {
|
|||||||
toTrigger:Array<TrackEvent>;
|
toTrigger:Array<TrackEvent>;
|
||||||
|
|
||||||
vlcUpdate(vlc:VlcUpdate) {
|
vlcUpdate(vlc:VlcUpdate) {
|
||||||
this.startTime = new Date().getTime() - vlc.time;
|
if(!vlc.is_playing){
|
||||||
this.filePlaying = vlc.file;
|
this.stop();
|
||||||
|
} else {
|
||||||
|
this.startTime = new Date().getTime() - vlc.time;
|
||||||
|
this.filePlaying = vlc.file;
|
||||||
|
console.log("vlc_update", vlc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(time:FrameTime) {
|
update(time:FrameTime) {
|
||||||
@ -125,6 +132,7 @@ class Timecode {
|
|||||||
var data:any = {};
|
var data:any = {};
|
||||||
data.time = new FrameTime(d);
|
data.time = new FrameTime(d);
|
||||||
data.track = this.activeTrack.id;
|
data.track = this.activeTrack.id;
|
||||||
|
data.filePlaying = this.filePlaying;
|
||||||
ios.emit("update", data);
|
ios.emit("update", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +154,7 @@ class Timecode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
play() {
|
play() {
|
||||||
|
if(!this.activeTrack)return;
|
||||||
if(this.filePlaying){
|
if(this.filePlaying){
|
||||||
ioClient.emit("play", {file:this.filePlaying});
|
ioClient.emit("play", {file:this.filePlaying});
|
||||||
ioClient.on("playing", ()=>{
|
ioClient.on("playing", ()=>{
|
||||||
@ -197,6 +206,7 @@ interface VlcUpdate {
|
|||||||
|
|
||||||
var timecode = new Timecode();
|
var timecode = new Timecode();
|
||||||
ios.on("connection", socket=>{
|
ios.on("connection", socket=>{
|
||||||
|
senddata();
|
||||||
function senddata(){
|
function senddata(){
|
||||||
ios.emit("get_data", {
|
ios.emit("get_data", {
|
||||||
tracks: db.getState(),
|
tracks: db.getState(),
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
<button onclick="startSequence()">Play</button>
|
<button onclick="startSequence()">Play</button>
|
||||||
<label >Loaded: </label>
|
<label >Loaded: </label>
|
||||||
<label id="loaded"></label>
|
<label id="loaded"></label>
|
||||||
|
<label >File playing: </label>
|
||||||
|
<label id="fplay"></label>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div id="track_select_div">
|
<div id="track_select_div">
|
||||||
@ -97,6 +99,7 @@
|
|||||||
if(selected.id !== data.track) return; //Nur wenn abgespielter track ausgewählt
|
if(selected.id !== data.track) return; //Nur wenn abgespielter track ausgewählt
|
||||||
timenow = data.time.lmilliseconds;
|
timenow = data.time.lmilliseconds;
|
||||||
$("#actualtime").html(data.time.lhours + ":" + data.time.lminutes + ":" + data.time.lseconds + ":" + data.time.lframe);
|
$("#actualtime").html(data.time.lhours + ":" + data.time.lminutes + ":" + data.time.lseconds + ":" + data.time.lframe);
|
||||||
|
$("#fplay").html(data.filePlaying);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#track_select").on("change", function () {
|
$("#track_select").on("change", function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user