dimanche 6 juillet 2014

node.js mplayer fifo control


Vote count:

0




I am trying to create an webscket control wrapper for mplayer on beaglebone with node.js. A glimpse of my websocket server looks lke this:



io.sockets.on('connection', function (socket)
{
SaveToLog('Client ' + clientAddress + ' connected.');
/* Function used to control the LEDs according to HTML file */

allClients.push(socket);

socket.on('miro_server', function (device, command)
{
SaveToLog(device + ' ' + command);

switch (device)
{
case 'mplayerStatus':
if(command == 'PLAYSELECTED')
{
ls = childProcess.exec('mplayer -slave -quiet -input file=/home/root/.mplayer/mplayer_fifo /home/root/agalloch.mp3',
function (error, stdout, stderr)
{
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null)
{
console.log('exec error: ' + error);
}
});

ls.on('exit', function (code)
{
console.log('Child process exited with exit code '+code);
});
}
else /* PAUSE */
{
childProcess.exec('echo "pause" > /home/root/.mplayer/mplayer_fifo',
function (error, stdout, stderr)
{
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null)
{
console.log('exec error: ' + error);
}
});
}
break;
}

});
});


The mplayer process starts correctly and I can hear music from the speakers, but the problem is that I cannot send any commands to the mplayer process via the selected fifo. When I try the same commands in the linux terminal, it works just fine, so I presume it has something to do with the node.js process exec part.


I do not have much experience with linux or node.js, and most of the code I've written is based on code examples and tutorials.


Can anyone explain what is going on and why I cannot send playback command via fifo to the mplayer process using node.js?


Thank you.



asked 31 secs ago






Aucun commentaire:

Enregistrer un commentaire