adding sstop updates

This commit is contained in:
Fabian Stamm 2017-06-20 13:35:06 +02:00
parent abf91edee6
commit c558e3dc86

View File

@ -15,6 +15,7 @@ io.on("connection", (socket)=>{
activeFile = data.file;
player.loadFile(__dirname + "/files/" + data.file, ()=>{
player.play(()=>{
Update.start();
socket.emit("playing", {file: data.file});
});
});
@ -22,12 +23,15 @@ io.on("connection", (socket)=>{
socket.on("stop", (data)=>{
player.stop(()=>{
Update.stop();
io.emit("stopped");
});
});
});
setInterval(()=>{
class Update {
static start() {
Update.interv = setInterval(()=>{
var start
var update_infos = {};
player.getTime((t)=>{
@ -39,6 +43,12 @@ setInterval(()=>{
io.emit("update", update_infos);
})
});
}, 1000/25)
}, 1000/25)
}
static stop() {
clearInterval(Update.interv);
}
}
http.listen(5000);