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,12 +23,15 @@ 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 {
static start() {
Update.interv = setInterval(()=>{
var start var start
var update_infos = {}; var update_infos = {};
player.getTime((t)=>{ player.getTime((t)=>{
@ -40,5 +44,11 @@ setInterval(()=>{
}) })
}); });
}, 1000/25) }, 1000/25)
}
static stop() {
clearInterval(Update.interv);
}
}
http.listen(5000); http.listen(5000);