From 692898fda12784f3b73c70efee3d11e18733c869 Mon Sep 17 00:00:00 2001 From: Gerrit Linnemann Date: Mon, 2 Nov 2015 15:59:21 +0100 Subject: [PATCH] ready4testing --- kitchenradio/app/radio.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/kitchenradio/app/radio.js b/kitchenradio/app/radio.js index a386545..4faa8b1 100644 --- a/kitchenradio/app/radio.js +++ b/kitchenradio/app/radio.js @@ -7,7 +7,7 @@ // load the things we need -var exec = require('child_process').exec; +var spawn = require('child_process').spawn; var App = null; @@ -52,12 +52,12 @@ exports.play = function(idx) { if(channel !== undefined) { var stream2play = channel.stream; - try { + /*try { var parsers = require("playlist-parser"); var M3U = parsers.M3U; var fs = require("fs"); - var playlist = M3U.parse(fs.readFileSync('/Users/gerrit/Downloads/swr3_m.m3u', { encoding: "utf8" })); + var playlist = M3U.parse(fs.readFileSync(channel.stream, { encoding: "utf8" })); Log.inspect('Radio: playlist', playlist); if(Helper.isDefinedAndNotNull(playlist[0])) { @@ -65,23 +65,23 @@ exports.play = function(idx) { } } catch(e) { Log.error(e); - } + }*/ - var ls = exec( - 'mplayer -slave -quiet ' + stream2play, - function (error, stdout, stderr) { - Log.log('Radio: stdout: ' + stdout); - Log.log('Radio: stderr: ' + stderr); - if (error !== null) { - Log.error('Radio: exec error: ' + error); - } - } + var child = spawn( + 'mplayer', + [ + '-slave', + '-quit', + 'stream2play' + ] ); - setTimeout(function() { exec('echo "pause"', function(error, stdout, stderr) {}); }, 4000); + child.stdout.on('data', function(chunk) { + Log.log('Radio: ' + chunk); + }); - ls.on('exit', function (code){ + child.on('exit', function (code){ Log.log('Radio: Child process exited with exit code ' + code); }); } else {