tags:

views:

296

answers:

1

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.

A: 

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.

John
It's rather late now I'm afraid, but that doesn't look quite a lot simpler. I'm going to accept it because no one else has suggested anything!
Martin
Have you looked at the Javas sound sampled packages? They support playing audio and you have a lot of control. Changing the volume is as simple as setting the new volume level. The problem though is that Java doesn't support mp3's so you need to use some other resource. Like the JLayer, or JMF etc. Unless you convert the format to something else.
John