node-omxplayer icon indicating copy to clipboard operation
node-omxplayer copied to clipboard

process immediately gets closed

Open oronbz opened this issue 7 years ago • 1 comments

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!

oronbz avatar Aug 09 '17 17:08 oronbz

I've found the issue! spawn doesn't recognize ~ as home folder but exec does. So we have two options:

  1. use the full path /home/pi/song.mp4
  2. I'll make a PR replacing ~ with process.env.HOME.

What do you say?

P.S I prefer option 2 (:

oronbz avatar Aug 09 '17 17:08 oronbz