How can I play an .mp3
and a .wav
file in my Java application? I am using Swing. I tried looking on the internet, for something like this example:<
To give the readers another alternative, I am suggesting JACo MP3 Player library, a cross platform java mp3 player.
Features:
For a complete list of its methods and attributes you can check its documentation here.
Sample code:
import jaco.mp3.player.MP3Player;
import java.io.File;
public class Example1 {
public static void main(String[] args) {
new MP3Player(new File("test.mp3")).play();
}
}
For more details, I created a simple tutorial here that includes a downloadable sourcecode.