volume, stop

This commit is contained in:
2015-11-16 15:24:28 +01:00
parent c0df1a1aed
commit 830bb50f14
10 changed files with 171 additions and 13 deletions
+32
View File
@@ -20,6 +20,8 @@ var Log = null
var Helper = null;
var Conf = null;
var volume = '40';
exports.init = function(Express, Configuration) {
App = Express;
@@ -33,6 +35,10 @@ exports.init = function(Express, Configuration) {
Log.log('Radio: Found channel ' + channel.title);
});
// set default volume level
Helper.shspawn('amixer scontrols');
Helper.shspawn('amixer sset \'PCM\' '+volume+'%');
return this;
}
@@ -78,4 +84,30 @@ exports.play = function(idx) {
} else {
Log.error('Radio: No channel defined!');
}
}
exports.stop = function() {
Log.log('Radio: stop playing');
Helper.shspawn(App.get('tools_root')+'action.sh stop');
}
exports.volumeUp = function() {
exports.volume(5)
}
exports.volumeDown = function() {
exports.volume(-5)
}
exports.volume = function(step) {
Log.log('Radio: volume ' + (step>0 ? 'up' : 'down'));
if(step != 0) {
volume = volume + step;
if(volume > 100) { volume = 100; }
if(volume < 0) { volume = 0; }
Helper.shspawn('amixer sset \'PCM\' '+volume+'%');
}
}