Can Java Sound be used to control the system volume?

前端 未结 6 1286
旧时难觅i
旧时难觅i 2020-11-29 10:22

Java Sound offers FloatControl instances for various sound line functionality, and both a MASTER_GAIN & VOLUME control type.

Can these controls be

6条回答
  •  没有蜡笔的小新
    2020-11-29 11:00

    try this it wont disappoint you.... we can modify upper example accordingly.

    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.FloatControl;
    import javax.sound.sampled.Line;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.Mixer;
    import javax.swing.BoxLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JProgressBar;
    
    public class SoundMeter {
    
    JFrame j;
    
    public SoundMeter() {
        j = new JFrame("SoundMeter");
        j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        j.setLayout(new BoxLayout(j.getContentPane(), BoxLayout.Y_AXIS));
        printMixersDetails();
        j.setVisible(true);
    }
    public void printMixersDetails(){
        javax.sound.sampled.Mixer.Info[] mixers = AudioSystem.getMixerInfo();
        System.out.println("There are " + mixers.length + " mixer info objects");  
        for(int i=0;i

提交回复
热议问题