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
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var fs = require("fs");
var http = require('http');
var wget = require('wget');
@ -69,14 +70,21 @@ exports.play = function(idx) {
Log.inspect('Radio: Download completed', output);
if(Helper.isDefinedAndNotNull(Child)) {
// kill active instances
try {
Child.kill();
} catch(err) {
Log.error('Radio: Error killing process');
}
}
var catProcess = exec('cat ' + m3u + ' | grep http://');
catProcess.stdout.on('data', function(data) {
Log.inspect('Radio: Play', data);
});
try {
/*try {
var parsers = require('playlist-parser');
var M3U = parsers.M3U;
@ -85,11 +93,13 @@ exports.play = function(idx) {
if(Helper.isDefinedAndNotNull(playlist[0])) {
stream2play = playlist[0].file;
} else {
}
} catch(e) {
Log.error(e);
}
}*/
var Child = spawn(
'mplayer',
[
@ -98,22 +108,25 @@ exports.play = function(idx) {
stream2play
]
);
// listen for any response from the child
Child.stdout.on('data', function(chunk) {
Log.log('Radio: ' + chunk);
Log.log('Radio: stdout: ' + chunk);
});
// listen for any errors
Child.stderr.on('data', function (chunk) {
Log.error('Radio: ' + chunk);
Log.error('Radio: stderr: ' + chunk);
});
/*Child.on('exit', function (code){
Log.log('Radio: Child process exited with exit code ' + code);
});*/
});
});
download.on('error', function(err) {
Log.error('Radio: Error downloading playlist. ' + err);
});
} else {
Log.error('Radio: No channel defined!');
}