ready4testing

This commit is contained in:
Gerrit Linnemann 2015-11-02 17:02:40 +01:00
parent a81efff715
commit 39a509ccaa

View File

@ -8,6 +8,7 @@
// load the things we need // load the things we need
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var fs = require("fs"); var fs = require("fs");
var http = require('http'); var http = require('http');
var wget = require('wget'); var wget = require('wget');
@ -69,6 +70,7 @@ exports.play = function(idx) {
Log.inspect('Radio: Download completed', output); Log.inspect('Radio: Download completed', output);
if(Helper.isDefinedAndNotNull(Child)) { if(Helper.isDefinedAndNotNull(Child)) {
// kill active instances
try { try {
Child.kill(); Child.kill();
} catch(err) { } catch(err) {
@ -76,7 +78,13 @@ exports.play = function(idx) {
} }
} }
try { var catProcess = exec('cat ' + m3u + ' | grep http://');
catProcess.stdout.on('data', function(data) {
Log.inspect('Radio: Play', data);
});
/*try {
var parsers = require('playlist-parser'); var parsers = require('playlist-parser');
var M3U = parsers.M3U; var M3U = parsers.M3U;
@ -85,10 +93,12 @@ exports.play = function(idx) {
if(Helper.isDefinedAndNotNull(playlist[0])) { if(Helper.isDefinedAndNotNull(playlist[0])) {
stream2play = playlist[0].file; stream2play = playlist[0].file;
} else {
} }
} catch(e) { } catch(e) {
Log.error(e); Log.error(e);
} }*/
var Child = spawn( var Child = spawn(
'mplayer', 'mplayer',
@ -101,18 +111,21 @@ exports.play = function(idx) {
// listen for any response from the child // listen for any response from the child
Child.stdout.on('data', function(chunk) { Child.stdout.on('data', function(chunk) {
Log.log('Radio: ' + chunk); Log.log('Radio: stdout: ' + chunk);
}); });
// listen for any errors // listen for any errors
Child.stderr.on('data', function (chunk) { Child.stderr.on('data', function (chunk) {
Log.error('Radio: ' + chunk); Log.error('Radio: stderr: ' + chunk);
}); });
/*Child.on('exit', function (code){ /*Child.on('exit', function (code){
Log.log('Radio: Child process exited with exit code ' + code); Log.log('Radio: Child process exited with exit code ' + code);
});*/ });*/
});
download.on('error', function(err) {
Log.error('Radio: Error downloading playlist. ' + err);
}); });
} else { } else {
Log.error('Radio: No channel defined!'); Log.error('Radio: No channel defined!');