ready4testing
This commit is contained in:
parent
a81efff715
commit
39a509ccaa
@ -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,14 +70,21 @@ 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) {
|
||||||
Log.error('Radio: Error killing process');
|
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 parsers = require('playlist-parser');
|
||||||
var M3U = parsers.M3U;
|
var M3U = parsers.M3U;
|
||||||
|
|
||||||
@ -85,11 +93,13 @@ 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',
|
||||||
[
|
[
|
||||||
@ -98,22 +108,25 @@ exports.play = function(idx) {
|
|||||||
stream2play
|
stream2play
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// 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!');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user