I'm trying to make a simple program that checks if a microphone is muted or not. This is the code I have for determine which Line the microphone is.
private Line getMic() throws LineUnavailableException {
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (int i = 0; i < mixerInfos.length; i++) {
Mixer mixer = AudioSystem.getMixer(mixerInfos[i]);
int maxLines = mixer.getMaxLines(Port.Info.MICROPHONE);
Port lineIn = null;
if (maxLines > 0) {
lineIn = (Port) mixer.getLine(Port.Info.MICROPHONE);
return lineIn;
}
}
return null;
}
Then from there I call the following:
BooleanControl muteControl = (BooleanControl)mic.getControl(BooleanControl.Type.MUTE);
System.out.println(muteControl.getValue());
However, I'm getting an error:
Unsupported control type: Mute
I went ahead and looked to see what Controls were available for the Line using the following:
for(Control c : mic.getControls()){
System.out.println(c.getType());
}
There is only one Control and it is the Master Volume. I'm not sure why the Mute control is not listed.
The line that is being returned in my getMic() function is returning the correct microphone. I have a USB headset plugged in and it is recognized by any application.