const DEBUG = process.env.debug | false; var p = require("./vlc_rc"); var player = new p.VLC_RC({verbose:true, debug:true, manual:false}); var http = require("http").createServer(); var io = require("socket.io")(http); var activeFile = undefined; io.on("connection", (socket)=>{ console.log("client connected:", socket.client.id); socket.on("play", (data)=>{ console.log("Play", data); activeFile = data.file; player.loadFile(__dirname + "/files/" + data.file, ()=>{ player.play(()=>{ Update.start(); socket.emit("playing", {file: data.file}); }); }); }); socket.on("stop", (data)=>{ player.stop(()=>{ Update.stop(); io.emit("stopped"); }); }); }); 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);