This discussion is archived
4 Replies Latest reply: Apr 12, 2013 5:28 AM by PhHein RSS

How can I control system's volume with java?

Squall867 Newbie
Currently Being Moderated
Hi, I'm trying to make a remote audio control and I need a way to set current volume by code.

After looking at java sound APIs I came up with this:
line = mixer.getLine(lineInfo);
boolean opened = line.isOpen() || line instanceof Clip;
     System.out.println("Line is not open, trying to open it...");;
     opened = true;
          FloatControl volumeCtrl = (FloatControl)line.getControl(FloatControl.Type.VOLUME);
               System.out.println("Current volume is: "+volumeCtrl.getValue());
I tried this code with every mixer I have (althought I think it's the "SPEAKER" one...) but I always get 1.0 as current volume, no matter what.
So, I'm getting something wrong..can you help me?:(


  • Correct Answers - 10 points
  • Helpful Answers - 5 points