|
|
|
|
@ -66,15 +66,26 @@ app.get('/videos', (req, res) => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let process = null;
|
|
|
|
|
let mayRestart = false;
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync('/tmp/video')) {
|
|
|
|
|
const initialVideo = fs.readFileSync('/tmp/video');
|
|
|
|
|
process = require('child_process').spawn('ffplay', ['-fs', '-loop', '2147483647', '-hide_banner', '-loglevel', 'error', initialVideo]);
|
|
|
|
|
|
|
|
|
|
process.on("exit", () => {
|
|
|
|
|
if (!mayRestart) {
|
|
|
|
|
process = require('child_process').spawn('ffplay', ['-fs', '-loop', '2147483647', '-hide_banner', '-loglevel', 'error', initialVideo]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs.mkdirSync('/video', { recursive: true });
|
|
|
|
|
|
|
|
|
|
app.post('/play', (req, res) => {
|
|
|
|
|
if (process) {
|
|
|
|
|
mayRestart = true;
|
|
|
|
|
process.kill();
|
|
|
|
|
mayRestart = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let video = req.query.video;
|
|
|
|
|
@ -98,6 +109,12 @@ app.post('/play', (req, res) => {
|
|
|
|
|
console.error(`stderr: ${data}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
process.on("exit", () => {
|
|
|
|
|
if (!mayRestart) {
|
|
|
|
|
process = require('child_process').spawn('ffplay', ['-fs', '-loop', '2147483647', '-hide_banner', '-loglevel', 'error', video]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
res.json({ status: 'ok' });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|