ready4testing

This commit is contained in:
2015-11-02 16:10:52 +01:00
parent 692898fda1
commit 753b78d18b
2 changed files with 27 additions and 5 deletions
+21 -5
View File
@@ -15,6 +15,8 @@ var Log = null
var Helper = null;
var Conf = null;
var Child = null;
exports.init = function(Express, Configuration) {
App = Express;
@@ -51,6 +53,14 @@ exports.play = function(idx) {
var channel = Conf.channels[idx];
if(channel !== undefined) {
var stream2play = channel.stream;
if(Helper.isDefinedAndNotNull(Child)) {
try {
Child.kill();
} catch(err) {
Log.error('Radio: Error killing process');
}
}
/*try {
var parsers = require("playlist-parser");
@@ -68,7 +78,7 @@ exports.play = function(idx) {
}*/
var child = spawn(
var Child = spawn(
'mplayer',
[
'-slave',
@@ -77,13 +87,19 @@ exports.play = function(idx) {
]
);
child.stdout.on('data', function(chunk) {
// listen for any response from the child
Child.stdout.on('data', function(chunk) {
Log.log('Radio: ' + chunk);
});
child.on('exit', function (code){
Log.log('Radio: Child process exited with exit code ' + code);
// listen for any errors
Child.stderr.on('data', function (chunk) {
Log.error('Radio: ' + chunk);
});
/*Child.on('exit', function (code){
Log.log('Radio: Child process exited with exit code ' + code);
});*/
} else {
Log.error('Radio: No channel defined!');
}