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