If you simply must use MP3, then use the JMF mp3plugin.jar from
http://java.sun.com/javase/technologies/desktop/media/jmf/mp3/download.htmlYou include it on your classpath using -Djava.library.path=<lib where jar is> etc.
Then use some code like this:
AudioInputStream din = null;
try {
SourceDataLine line;
do {
AudioInputStream in = AudioSystem.getAudioInputStream(<mp3Filename>);
AudioFormat baseFormat = in.getFormat();
AudioFormat decodedFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
baseFormat.getChannels() * 2, baseFormat.getSampleRate(),
false);
din = AudioSystem.getAudioInputStream(decodedFormat, in);
DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
line = (SourceDataLine) AudioSystem.getLine(info);
if(line != null) {
int nBytesRead;
line.open(decodedFormat);
byte[] data = new byte[1024];
// Start
line.start();
while ((nBytesRead = din.read(data, 0, data.length)) != -1 && !fadeComplete) {
line.write(data, 0, nBytesRead);
}
}
// Stop
line.drain();
line.stop();
line.close();
din.close();
} while(loopMusic);
} catch(Exception e) {
e.printStackTrace();
} finally {
if(din != null) {
try { din.close(); } catch(IOException e) { e.printStackTrace(); }
}
}