stop before play

This commit is contained in:
Gerrit Linnemann 2015-11-15 23:00:01 +01:00
parent 7b3591a206
commit 32fbba6c67
3 changed files with 24 additions and 50 deletions

View File

@ -11,7 +11,8 @@ var os = require('os')
, dns = require('dns') , dns = require('dns')
, Log = require('./logging') , Log = require('./logging')
, Crypto = require('crypto') , Crypto = require('crypto')
, interfaceAddresses = require('interface-addresses'); , interfaceAddresses = require('interface-addresses'),
, spawn = require('child_process').spawn;
var app = null; var app = null;
@ -26,8 +27,11 @@ exports.init = function(express) {
return this; return this;
} }
exports.shspawn = function(command) {
spawn('sh', ['-c', command], { stdio: 'inherit' });
}
exports.timeSince = function timeSince(date) { exports.timeSince = function(date) {
var seconds = Math.floor((new Date() - date) / 1000); var seconds = Math.floor((new Date() - date) / 1000);

View File

@ -80,54 +80,9 @@ exports.play = function(idx) {
} }
/*grep('http://', m3u, function(list){ Child.stdin.pause();
Log.inspect('Radio: grep', list); Child.kill();
});*/ Helper.shspawn(App.get('tools_root')+'action.sh play');
/*try {
var parsers = require('playlist-parser');
var M3U = parsers.M3U;
var playlist = M3U.parse(fs.readFileSync(m3u, { encoding: 'utf8' }));
Log.inspect('Radio: playlist', playlist);
if(Helper.isDefinedAndNotNull(playlist[0])) {
stream2play = playlist[0].file;
} else {
}
} catch(e) {
Log.error(e);
}*/
/*var Child = spawn(
App.get('tools_root')+'action.sh',
['play']
);*/
child = exec(App.get('tools_root')+'action.sh play',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
// listen for any response from the child
Child.stdout.on('data', function(chunk) {
Log.log('Radio: stdout: ' + chunk);
});
// listen for any errors
Child.stderr.on('data', function (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) { download.on('error', function(err) {

15
kitchenradio/bin/stop_radio.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
# V0.1
### DEFINITIONS
MY_PATH="$(pwd)"
. $MY_PATH/bin/_inc/def_text_coloring.sh
### PRORGAM
echo
echo "${BGre}Stop playing ...${RCol}"
echo