win-audio
Version:
Get, Set and Watch Speaker/Microphone Volume on Windows
108 lines (67 loc) • 2.04 kB
Markdown
Get, Set and Watch Speaker/Microphone Volume on Windows
[](https://ci.appveyor.com/project/fcannizzaro/win-audio)
[](https://www.npmjs.com/package/win-audio)
[](https://www.npmjs.com/package/win-audio)
```sh
npm i --save win-audio
```
[](https://github.com/nodejs/node-gyp#installation) to build **audio-napi.cc**
This version requires **N-API**, and **node** version **>= 8.6.0**
```javascript
const win = require('win-audio');
// manage speaker volume
const speaker = win.speaker;
// manage mic volume
const microphone = win.mic;
```
```javascript
const audio = require('win-audio').speaker;
audio.polling(200);
audio.events.on('change', (volume) => {
console.log("old %d%% -> new %d%%", volume.old, volume.new);
});
audio.events.on('toggle', (status) => {
console.log("muted: %s -> %s", status.old, status.new);
});
audio.set(40);
audio.increase(20);
audio.decrease(10);
audio.mute();
```
- interval: milliseconds for check volume changes.
**Return** current percentage of volume.
**Return** if speaker/mic is muted.
Set a new master volume.
- value: percentage of new volume. **[0-100]**
Increase current volume of value %.
- value: percentage. **[0-100]**
Decrease current volume of value %.
- value: percentage. **[0-100]**
Mute volume.
Unmute volume.
Mute/Unmute volume according to current status.
Called when volume is changed.
Called when volume is muted/unmuted.
[](https://github.com/11AND2)
Francesco Saverio Cannizzaro