Controlling volume in a java application

烂漫一生 提交于 2019-12-01 18:29:16

Sometimes the controls are nested, which makes a platform independent solution difficult. I have written an utility class which is used like that:

Audio.setMasterOutputVolume(0.5f);

Source code is here: https://github.com/Kunagi/ilarkesto/blob/master/src/main/java/ilarkesto/media/Audio.java

Stackoverflow users can use the code from Audio.java under the terms of the WTFPL.

I don't think there is a constant called VOLUME. Its MASTER_GAIN. So you should do

volCtrl = (floatControl) lineIn.getControl(FloatControl.Type.MASTER_GAIN);
volCtrl.setValue(you_custom_value);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!