MP3 is a bit of a format to avoid when it comes to Java, since it isn't natively supported. If you could sacrifice the MP3s for MIDI or WAV files, a quick and easy method you could include would be something like:
Code:
public AudioClip loadSound(String filename) {
URL soundPath = getClass().getResource(filename);
return Applet.newAudioClip(soundPath);
}
To access this method, just initialise a variable of type AudioClip, and pass the method the name or path of the string:
Code:
AudioClip sound = loadSound("hello.wav");
To start or stop the sound from playing:
Code:
sound.play();
sound.stop();
Also, note that to use this method, you need to import the java.net.* and java.applet.* packages.