我无法在Windows 上检测默认麦克风音量设置而不使用jni 。我尝试了几种方法,但它没有按预期工作
public static float getVolume() {
float volume = 0;
try {
if (AudioSystem.isLineSupported(Port.Info.MICROPHONE)) {
Port lineInx = (Port) AudioSystem.getLine(Port.Info.MICROPHONE);
lineInx.open();
FloatControl fx = null;
Control[] vx = lineInx.getControls();
fx = getVolumeControl(vx, 0);
volume = fx.getValue();
lineInx.close();
}
} catch (Exception ex) {
}
return volume;
}