small improvements

This commit is contained in:
Fabian Stamm 2017-06-20 14:34:08 +02:00
parent 49d584e989
commit 3c37537365
3 changed files with 47 additions and 9 deletions

View File

@ -35,9 +35,12 @@ class FrameTime {
this.lhours = millis.hours; this.lhours = millis.hours;
this.calcMillis(); this.calcMillis();
} }
else if (Number.isInteger(millis.milliseconds)) { else if (Number.isInteger(Number(millis.milliseconds))) {
this.milliseconds = millis.milliseconds; this.milliseconds = millis.milliseconds;
} }
else if (Number.isInteger(Number(millis.lmilliseconds))) {
this.milliseconds = millis.lmilliseconds;
}
} }
} }
get milliseconds() { get milliseconds() {
@ -90,12 +93,27 @@ class Timecode {
vlcUpdate(vlc) { vlcUpdate(vlc) {
if (!vlc.is_playing) { if (!vlc.is_playing) {
this.stop(); this.stop();
return;
} }
else { else {
this.startTime = new Date().getTime() - vlc.time; this.startTime = new Date().getTime() - vlc.time;
this.filePlaying = vlc.file; this.filePlaying = vlc.file;
console.log("vlc_update", vlc);
} }
var d = vlc.time;
this.toTrigger.forEach(e => {
if (e.time.milliseconds <= d) {
console.log(e);
ios.emit("artnet", e.art);
artnet.set(universe, e.art.subnet);
var i = this.toTrigger.indexOf(e);
this.toTrigger.splice(i, 1);
}
});
var data = {};
data.time = new FrameTime(d);
data.track = this.activeTrack.id;
data.filePlaying = this.filePlaying;
ios.emit("update", data);
} }
update(time) { update(time) {
var d = new Date().getTime() - this.startTime; var d = new Date().getTime() - this.startTime;
@ -137,7 +155,7 @@ class Timecode {
ioClient.emit("play", { file: this.filePlaying }); ioClient.emit("play", { file: this.filePlaying });
ioClient.on("playing", () => { ioClient.on("playing", () => {
this.startTime = new Date().getTime(); this.startTime = new Date().getTime();
this.interval = setInterval(this.update.bind(this), 1000 / 25); //this.interval = setInterval(this.update.bind(this), 1000/25);
this.playing = true; this.playing = true;
}); });
ioClient.on("update", (data) => { ioClient.on("update", (data) => {
@ -191,7 +209,8 @@ ios.on("connection", socket => {
}); });
socket.on("stop", () => { socket.on("stop", () => {
timecode.stop(); timecode.stop();
timecode.loadTrack(timecode.activeTrack.id); if (timecode.activeTrack)
timecode.loadTrack(timecode.activeTrack.id);
}); });
socket.on("create", (data) => { socket.on("create", (data) => {
var track = new Track(); var track = new Track();

File diff suppressed because one or more lines are too long

View File

@ -35,8 +35,10 @@ class FrameTime{
this.lminutes = millis.minutes; this.lminutes = millis.minutes;
this.lhours = millis.hours; this.lhours = millis.hours;
this.calcMillis(); this.calcMillis();
} else if(Number.isInteger(millis.milliseconds)){ } else if(Number.isInteger(Number(millis.milliseconds))){
this.milliseconds = millis.milliseconds; this.milliseconds = millis.milliseconds;
} else if(Number.isInteger(Number(millis.lmilliseconds))){
this.milliseconds = millis.lmilliseconds;
} }
} }
} }
@ -111,11 +113,27 @@ class Timecode {
vlcUpdate(vlc:VlcUpdate) { vlcUpdate(vlc:VlcUpdate) {
if(!vlc.is_playing){ if(!vlc.is_playing){
this.stop(); this.stop();
return;
} else { } else {
this.startTime = new Date().getTime() - vlc.time; this.startTime = new Date().getTime() - vlc.time;
this.filePlaying = vlc.file; this.filePlaying = vlc.file;
console.log("vlc_update", vlc); //console.log("vlc_update", vlc);
} }
var d = vlc.time;
this.toTrigger.forEach(e=>{
if(e.time.milliseconds <= d) {
console.log(e);
ios.emit("artnet", e.art);
artnet.set(universe, e.art.subnet)
var i = this.toTrigger.indexOf(e);
this.toTrigger.splice(i, 1);
}
});
var data:any = {};
data.time = new FrameTime(d);
data.track = this.activeTrack.id;
data.filePlaying = this.filePlaying;
ios.emit("update", data);
} }
update(time:FrameTime) { update(time:FrameTime) {
@ -159,7 +177,7 @@ class Timecode {
ioClient.emit("play", {file:this.filePlaying}); ioClient.emit("play", {file:this.filePlaying});
ioClient.on("playing", ()=>{ ioClient.on("playing", ()=>{
this.startTime = new Date().getTime(); this.startTime = new Date().getTime();
this.interval = setInterval(this.update.bind(this), 1000/25); //this.interval = setInterval(this.update.bind(this), 1000/25);
this.playing = true; this.playing = true;
}); });
ioClient.on("update", (data)=>{ ioClient.on("update", (data)=>{
@ -233,7 +251,8 @@ ios.on("connection", socket=>{
}); });
socket.on("stop", ()=>{ socket.on("stop", ()=>{
timecode.stop(); timecode.stop();
timecode.loadTrack(timecode.activeTrack.id); if(timecode.activeTrack)
timecode.loadTrack(timecode.activeTrack.id);
}); });
socket.on("create", (data)=>{ socket.on("create", (data)=>{
var track = new Track(); var track = new Track();