我必须得到系统音频(混音器)。我试过这个:
Mixer.Info[] info = AudioSystem.getMixerInfo();
try {
for(Mixer.Info i : info) {
Mixer mixer = AudioSystem.getMixer(i);
Line.Info[] linesInfo = mixer.getTargetLineInfo();
for(Line.Info lineInfo : linesInfo) {
Line line = mixer.getLine(lineInfo);
line.open();
if(line.isControlSupported(FloatControl.Type.VOLUME)) {
FloatControl control = (FloatControl) line.getControl(FloatControl.Type.VOLUME);
System.out.println(control.getValue());
}
}
}
}
catch(LineUnavailableException e) {
e.printStackTrace();
}
但它抛出LineUnavailableException(s):
javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian not supported.
at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(DirectAudioDevice.java:513)
at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:121)
at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:413)
如有必要,我可以使用外部库。