Search code examples
javajavasoundjslider

How do I control the volume of my PC speakers with a JSlider?


I'm currently writing a program in Java that I would like to use to control my PC's main speakers with. At the moment I am trying to use a JSlider. Is there a way that I can use ChangeListener to do this? If not ChangeListener, is there another way that I can integrate this into my program? I have tirelessly been searching the web for this.


Solution

  • Warning: the Java Tutorials on sound aren't the easiest read.

    http://docs.oracle.com/javase/tutorial/sound/accessing.html This one will show you how to find out what is on your system. You will need to figure out which line or port corresponds to OS speaker outputs.

    http://docs.oracle.com/javase/tutorial/sound/controls.html This one will show you how to place a Control on the line or port. You will then be tieing your JSlider output to this Control.

    Maybe start with that and come back with more specific questions along the way, if (when!) you run into problems.