Get, Set and Watch Speaker/Microphone Volume on Windows
npm i --save win-audio
node-gyp to build audio-napi.cc
This version requires N-API, and node version >= 8.6.0
const win = require('win-audio');
// manage speaker volume
const speaker = win.speaker;
// manage mic volume
const microphone = win.mic;
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.
Francesco Saverio Cannizzaro