我想用一个命令来调高或调低计算机的主音量(100%/0%)。
我看到我可以使用FloatControl
,但我不知道如何使用它。
看看看看使用JavaSound控制主音量 http://www.coderanch.com/t/492931/java/java/Adjusting-master-volume-Windows-XP.
从链接:
Mixer.Info [] mixers = AudioSystem.getMixerInfo();
System.out.println("There are " + mixers.length + " mixer info objects");
for (Mixer.Info mixerInfo : mixers)
{
System.out.println("Mixer name: " + mixerInfo.getName());
Mixer mixer = AudioSystem.getMixer(mixerInfo);
Line.Info [] lineInfos = mixer.getTargetLineInfo(); // target, not source
for (Line.Info lineInfo : lineInfos)
{
System.out.println(" Line.Info: " + lineInfo);
Line line = null;
boolean opened = true;
try
{
line = mixer.getLine(lineInfo);
opened = line.isOpen() || line instanceof Clip;
if (!opened)
{
line.open();
}
FloatControl volCtrl = (FloatControl)line.getControl(FloatControl.Type.VOLUME);
System.out.println(" volCtrl.getValue() = " + volCtrl.getValue());
}
catch (LineUnavailableException e)
{
e.printStackTrace();
}
catch (IllegalArgumentException iaEx)
{
System.out.println(" " + iaEx);
}
finally
{
if (line != null && !opened)
{
line.close();
}
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)