diff --git a/index.js b/index.js index 7437f24..b55c46a 100755 --- a/index.js +++ b/index.js @@ -138,8 +138,7 @@ app.post("/select", (req, res) => { }); app.post("/playoverlay", (req, res) => { - let video = fs.readFileSync('/overlayvideo'); - require('child_process').spawn('ffplay', ['-fs', '-autoexit', '-hide_banner', '-loglevel', 'error', video]); + require('child_process').spawn('/home/pi/video-player/play-overlay.sh'); res.json({ status: 'ok' }); }); @@ -179,11 +178,5 @@ app.post('/upload', function (req, res) { } }); - try { - require('child_process').spawn('sudo', ['systemctl', 'restart', 'video-player2.service']); - } catch (error) { - console.error(error); - } - res.redirect('/'); }); diff --git a/play-overlay.sh b/play-overlay.sh index 8cacac7..990a4b8 100755 --- a/play-overlay.sh +++ b/play-overlay.sh @@ -1,5 +1,9 @@ #!/bin/bash +/home/pi/video-player/relay-on.sh & + export DISPLAY=:0 ffplay -fs -autoexit $(cat /overlayvideo) + +/home/pi/video-player/relay-off.sh & diff --git a/public/index.html b/public/index.html index 834841a..1d4c73c 100755 --- a/public/index.html +++ b/public/index.html @@ -39,6 +39,22 @@
+

Relay 1

+
+ + +

Relay 2

+
+ + +

Relay 3

+
+ + +

Relay 4

+
+ + diff --git a/public/main.js b/public/main.js index 460863b..18c4290 100755 --- a/public/main.js +++ b/public/main.js @@ -34,6 +34,16 @@ async function main() { status1.textContent = status.status1; status2.textContent = status.status2; + + const relay1Div = document.getElementById('relay1'); + const relay2Div = document.getElementById('relay2'); + const relay3Div = document.getElementById('relay3'); + const relay4Div = document.getElementById('relay4'); + + relay1Div.innerText = await (await fetch("10.242.84.111:8080/status/19")).text(); + relay2Div.innerText = await (await fetch("10.242.84.111:8080/status/13")).text(); + relay3Div.innerText = await (await fetch("10.242.84.111:8080/status/6")).text(); + relay4Div.innerText = await (await fetch("10.242.84.111:8080/status/5")).text(); } main(); diff --git a/relay-off.sh b/relay-off.sh new file mode 100644 index 0000000..f746a1c --- /dev/null +++ b/relay-off.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Relay 1: GPIO 19 +# Relay 2: GPIO 13 +# Relay 3: GPIO 6 +# Relay 4: GPIO 5 + +curl --retry 5 --retry-all-errors 10.242.84.111:8080/off/19 diff --git a/relay-on.sh b/relay-on.sh new file mode 100644 index 0000000..6cc4845 --- /dev/null +++ b/relay-on.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Relay 1: GPIO 19 +# Relay 2: GPIO 13 +# Relay 3: GPIO 6 +# Relay 4: GPIO 5 + +curl --retry 5 --retry-all-errors 10.242.84.111:8080/on/19