Getting the system audio levels in Java

前端 未结 4 1155
故里飘歌
故里飘歌 2021-01-13 19:15

How does one get the master volume in Java? I want to make a program that displays (NOT CHANGE) this value (probably on a JProgressBar or somet

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 19:55

    Although JProgressBar is not used for this
    This might Help

    package test;
    
    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

提交回复
热议问题