Java API sound
Hi
I'm trying to use JAva sound API but I have an error on some computers
with this code :
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
public class ControlTest {
public static void main(String[] args) throws
LineUnavailableException, InterruptedException {
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (int i = 0; i < mixerInfos.length; i++) {
System.out.println("AudioSystem info Name
:"+mixerInfos[i].toString());
Mixer mixer = AudioSystem.getMixer(mixerInfos[i]);
Line.Info[] targetLineInfos = mixer.getTargetLineInfo();
System.out.println("target infos : " +
targetLineInfos.length);
for (int j = 0; j < targetLineInfos.length; j++) {
setVolume(targetLineInfos[j]);
}
}
}
static boolean setVolume(Line.Info lineInfo) {
try {
System.out.println(lineInfo);
Line line = AudioSystem.getLine(lineInfo);
System.out.println("open " + line.getLineInfo());
line.open();
BooleanControl muteControl
=(BooleanControl)line.getControl(BooleanControl.Type.MUTE);
System.out.println("mute " + muteControl);
muteControl.setValue(true);
FloatControl control =
(FloatControl)line.getControl(FloatControl.Type.VOLUME);
control.setValue(control.getMinimum());
System.out.println("val " + control.getValue());
FloatControl controlp =
(FloatControl)line.getControl(FloatControl.Type.MASTER_GAIN);
controlp.setValue(control.getMinimum());
System.out.println("val " + controlp.getValue());
line.close();
} catch (Exception e) {
System.out.println(e);
return false;
}
return true;
}
}
Error :
java.lang.IllegalArgumentException: Unsupported control type: Mute
Is there a solution to control it ? Because I can control the Speaker
Sound but not microphone...
Thanks for your ideas
Meric pour vos idees d avance =]