Added settings file and removed videos from repo
Created settings.json that contains the settings Created .gitignore that ignores the videos folder Modified index.js to take the settings settings.json Modified client.js to take the WebSocket settings from the window
This commit is contained in:
parent
828697aa68
commit
bfdd897a20
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/vidoes
|
11
client.js
11
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; }
|
||||
|
||||
|
5
index.js
5
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(){
|
||||
|
5
settings.json
Normal file
5
settings.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"server_ip": "192.168.68.118",
|
||||
"server_port": 3000,
|
||||
"video_path": "videos/bigbuck.mp4"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user