stop before play
This commit is contained in:
parent
7b3591a206
commit
32fbba6c67
@ -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);
|
||||||
|
|
||||||
|
|||||||
@ -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
15
kitchenradio/bin/stop_radio.sh
Executable 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
|
||||||
Loading…
x
Reference in New Issue
Block a user