other
Filip Borum Poulsen 1 year ago
parent a0f3153c26
commit dcdf469996

@ -68,21 +68,21 @@ app.get('/videos', (req, res) => {
let process = null;
let mayRestart = false;
// if (fs.existsSync('/tmp/video')) {
// const initialVideo = fs.readFileSync('/tmp/video');
// startVideo(initialVideo);
// }
if (fs.existsSync('/selectedvideo')) {
const initialVideo = fs.readFileSync('/selectedvideo');
startVideo(initialVideo);
}
function startVideo(path) {
process = require('child_process').spawn('ffplay', ['-fs', '-loop', '2147483647', '-hide_banner', '-loglevel', 'error', path]);
process.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
// process.stdout.on('data', (data) => {
// console.log(`stdout: ${data}`);
// });
process.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
// process.stderr.on('data', (data) => {
// console.error(`stderr: ${data}`);
// });
process.on("exit", () => {
if (!mayRestart) {
@ -109,7 +109,7 @@ app.post('/play', (req, res) => {
video = path.join('/video/', path.basename(video))
}
fs.writeFileSync('/tmp/video', video);
fs.writeFileSync('/selectedvideo', video);
startVideo(video);
@ -123,9 +123,12 @@ app.post('/upload', function (req, res) {
}
// The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
const uploadPath = path.join(__dirname, '/public/videos/');
// const uploadPath = path.join(__dirname, '/public/videos/');
const uploadPath = "/video";
req.files.file.mv(uploadPath + "video.mp4", function (err) {
console.log(req.files.file);
req.files.file.mv(path.join(uploadPath, req.files.file.name), function (err) {
if (err) {
return res.status(500);
}
@ -138,4 +141,4 @@ app.post('/upload', function (req, res) {
}
res.redirect('/');
});
});

@ -3,12 +3,12 @@ Description=Video Player
After=multi-user.target
[Service]
WorkingDirectory=/home/steady/video-player
ExecStart=node /home/steady/video-player/index.js
WorkingDirectory=/home/pi/video-player
ExecStart=node /home/pi/video-player/index.js
Environment=DISPLAY=:0
User=1000
Group=1000
Restart=always
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target

@ -2,10 +2,10 @@
Description=Video Player
[Service]
WorkingDirectory=/home/steady/video-player
ExecStart=ffplay -fs -loop 2147483647 /home/steady/video-player/public/videos/video.mp4
WorkingDirectory=/home/pi/video-player
ExecStart=ffplay -fs -loop 2147483647 $(cat /selectedvideo)
Environment=DISPLAY=:0
Environment=AUDIODEV="hw:2,0"
User=1000
Group=1000
Restart=always
Restart=always

Loading…
Cancel
Save