diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6aa7838 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vidoes \ No newline at end of file diff --git a/client.js b/client.js index 03fd9cd..e969b18 100644 --- a/client.js +++ b/client.js @@ -1,6 +1,5 @@ const vid = document.querySelector('video') -const socket = new WebSocket('ws://192.168.68.118:3000'); - +const socket = new WebSocket(`ws://${window.location.hostname}:${window.location.port}`); // if the new tms is within this margin of the current tms, then the change is ignored for smoother viewing const PLAYING_THRESH = 1 const PAUSED_THRESH = 0.01 @@ -130,6 +129,14 @@ function get_global_time(delta = 0) { return d.getTime() + delta; } +async function get_settings() { + let s = null; + await fetch('settings.json') + .then((response)=>response.json()) + .then((responseJson)=>{s = responseJson}); + return s; +} + function median(values) { if(values.length === 0) { return 0; } diff --git a/index.js b/index.js index cfe0f25..d2d886f 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const server = require('http').createServer(app); const WebSocket = require('ws'); const wss = new WebSocket.Server({ server:server }); +const settings = JSON.parse(fs.readFileSync("settings.json")); const THRESH_IGNORANCE = 250; let users_amount = 0; @@ -83,7 +84,7 @@ app.get("/video", function (req, res) { } // get video stats (about 61MB) - const videoPath = "videos/Shreksophone_Original.mp4"; + const videoPath = settings.video_path; const videoSize = fs.statSync(videoPath).size; // Parse Range @@ -111,7 +112,7 @@ app.get("/video", function (req, res) { videoStream.pipe(res); }); -server.listen(3000, () => console.log(`Listening on port: 3000`)); +server.listen(settings.server_port, settings.server_ip, () => console.log(`Listening on port: 3000`)); function get_time(){ diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..2a57c3e --- /dev/null +++ b/settings.json @@ -0,0 +1,5 @@ +{ + "server_ip": "192.168.68.118", + "server_port": 3000, + "video_path": "videos/bigbuck.mp4" +} \ No newline at end of file