Search code examples
javaaudiojlayer

Playing multiple sounds and controlling the volume using java


I'm writing an application which plays multiple sounds concurrently, each sound needs to be played at a different volume. Once a sound is playing I never need to change its volume, which may simplify things somewhat. I cannot find a good way to do this.

I can't find a way to play an mp3 sound at a set volume using Java.

The JLayer library seems to have some capabilities for changing the volume, but I cannot find any references or tutorials for this, and the documentation is a little lacking.


Solution

  • Instead of JLayer you could look into JMF. Here is the link http://java.sun.com/javase/technologies/desktop/media/jmf/mp3/download.html Then it looks like you can control the volume using their media player. http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/apidocs/javax/media/bean/playerbean/MediaPlayer.html I hope this helps, I haven't tried it but the links look promising.