forked from bencevans/node-sonos
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathlogicalDeviceVolume.js
More file actions
40 lines (29 loc) · 815 Bytes
/
logicalDeviceVolume.js
File metadata and controls
40 lines (29 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var Sonos = require('../');
var keypress = require('keypress');
Sonos.LogicalDevice.search(function(err, groups) {
console.log(err, groups);
});
var dev = new Sonos.LogicalDevice([
{ host: '172.17.106.196', port: 1400 },
{ host: '172.17.107.66', port: 1400 }
]);
dev.initialize(function() {
console.log('use up / down keys to change volume');
keypress(process.stdin);
process.stdin.on('keypress', function (ch, key) {
if (key.name === 'down') {
dev.getVolume(function(vol) {
dev.setVolume(vol - 5);
});
} else if (key.name === 'up') {
dev.getVolume(function(vol) {
dev.setVolume(vol + 5);
});
}
if (key && key.ctrl && key.name === 'c') {
process.exit();
}
});
process.stdin.setRawMode(true);
process.stdin.resume();
});