I have a POST function in which I am trying to start VLC player using the child_process. I am using the latest Raspbian version.
router.post('/', function (req, res) {
let spawn = require('child_process').spawn;
let vlc = spawn('vlc');
vlc.stderr.on('data', function(data) {
console.log(data.toString());
});
vlc.on('exit', function(code){
console.log('Exit code: ' + code);
});
res.send({success: true})
});
After triggering the request, I get this message:
VLC is not supposed to be run as root. Sorry. If you need to use real-time priorities and/or privileged TCP ports you can use vlc-wrapper (make sure it is Set-UID root and cannot be run by non-trusted users first).
Since VLC cannot be run as root, I added the UID argument to the vlc start script, and it now looks like this:
let vlc = spawn('vlc' ,{uid: 1000});
Where UID: 1000 is the ID of the user I always use.
After triggering the request, I get another message in the log:
[016f9960] main libvlc error: cannot open config file (/root/.config/vlc/vlcrc): Permission denied
Home directory not accessible: Permission denied
[01762eb0] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
[0176bde8] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[0176bde8] main interface error: no suitable interface module [016f9960] main libvlc error: interface "dbus,none" initialization failed
[0176c7a8] main interface error: no suitable interface module [016f9960] main libvlc error: interface "globalhotkeys,none" initialization failed
[016f9960] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
error: XDG_RUNTIME_DIR not set in the environment.
[0176c7a8] skins2 interface error: cannot initialize OSFactory
[017614e0] main playlist: playlist is empty
[0176c7a8] [cli] lua interface: Listening on host "*console".
The player doesn't run. But if I run the same command via ssh, it will run. What could cause node from not running it?