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,23 +23,32 @@ io.on("connection", (socket)=>{
socket.on("stop", (data)=>{
player.stop(()=>{
Update.stop();
io.emit("stopped");
});
});
});
setInterval(()=>{
var start
var update_infos = {};
player.getTime((t)=>{
player.getState((playing)=>{
update_infos.file = activeFile;
update_infos.time = t;
update_infos.is_playing = playing;
//update_infos.
io.emit("update", update_infos);
})
});
}, 1000/25)
class Update {
static start() {
Update.interv = setInterval(()=>{
var start
var update_infos = {};
player.getTime((t)=>{
player.getState((playing)=>{
update_infos.file = activeFile;
update_infos.time = t;
update_infos.is_playing = playing;
//update_infos.
io.emit("update", update_infos);
})
});
}, 1000/25)
}
static stop() {
clearInterval(Update.interv);
}
}
http.listen(5000);