me and a friend are programming a MP3 Player as a schoolproject. We are nearly finished and now stuck at the point where we try to programm a function to change the volume o
JLGUI is a good example of a UI-based JLayer app adjusting volume. You can get the source code in the tar.gz file. http://www.javazoom.net/jlgui/sources.html
if (src == ui.getAcVolume())
{
Object[] args = { String.valueOf(ui.getAcVolume().getValue()) };
String volumeText = MessageFormat.format(ui.getResource("slider.volume.text"), args);
ui.getAcTitleLabel().setAcText(volumeText);
try
{
int gainValue = ui.getAcVolume().getValue();
int maxGain = ui.getAcVolume().getMaximum();
if (gainValue == 0) theSoundPlayer.setGain(0);
else theSoundPlayer.setGain(((double) gainValue / (double) maxGain));
config.setVolume(gainValue);
}
catch (BasicPlayerException ex)
{
log.debug("Cannot set gain", ex);
}
}