node-omxplayer
node-omxplayer copied to clipboard
process immediately gets closed
Hi,
I've try to use your library with this piece of code:
var Omx = require('node-omxplayer');
var player = Omx('~/song.mp4');
player.on('close', function() {
console.log('player closed!!!!');
});
player.on('error', function() {
console.log('error happened!');
});
but the issue is it's immediately printing:
player closed!!!!
the player doesn't even open.
As a side note when I open omxplayer
with exec it works well:
var exec = require('child_process').exec;
exec('omxplayer ~/song.mp4');
but with spawn
(which your library uses) it again, immediately closing
var spawn = require('child_process').spawn;
var args = [ '~/song.mp4' ];
spawn('omxplayer', args);
I'm running this on latest raspbian, with nodejs v6.11.2
Have any suggestions how to solve it? Thanks!
I've found the issue!
spawn
doesn't recognize ~
as home folder but exec does.
So we have two options:
- use the full path
/home/pi/song.mp4
- I'll make a PR replacing
~
withprocess.env.HOME
.
What do you say?
P.S I prefer option 2 (: