Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Another (non-JLayer) way to adjust the PC's speaker volume is to use classes in the javax.sound.sampled package provided by Sun/Oracle.</p> <p>On my machine, SPEAKER was the only output target supported.</p> <pre><code>import javax.sound.sampled.AudioSystem; import javax.sound.sampled.FloatControl; import javax.sound.sampled.Line.Info; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.Port; public class SoundVolumeDemo { public static void main(String[] args) { Info source = Port.Info.SPEAKER; // source = Port.Info.LINE_OUT; // source = Port.Info.HEADPHONE; if (AudioSystem.isLineSupported(source)) { try { Port outline = (Port) AudioSystem.getLine(source); outline.open(); FloatControl volumeControl = (FloatControl) outline.getControl(FloatControl.Type.VOLUME); System.out.println(" volume: " + volumeControl.getValue() ); float v = 0.33F; volumeControl.setValue(v); System.out.println(" new volume: " + volumeControl.getValue() ); v = 0.73F; volumeControl.setValue(v); System.out.println("newest volume: " + volumeControl.getValue() ); } catch (LineUnavailableException ex) { System.err.println("source not supported"); ex.printStackTrace(); } } } } </code></pre> <p>This is how I am achieving volume control in this app:</p> <p><a href="http://onebeartoe.com/media-players/randomjuke/filesystem/java-web-start/swing/index.jsp" rel="nofollow">http://onebeartoe.com/media-players/randomjuke/filesystem/java-web-start/swing/index.jsp</a></p> <p>Please note that I have only had experience with it working on MS Windows OS machines.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload