package others.interesting;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
public class MP3Player {
private String fileName;
private Player player;
public MP3Player(String fileName) {
this.fileName = fileName;
}
public void play() {
try {
BufferedInputStream buffer = new BufferedInputStream(
new FileInputStream(fileName));
player = new Player(buffer);
player.play();
} catch (FileNotFoundException e) {
System.err.println("FileNotFoundException:");
e.printStackTrace();
} catch (JavaLayerException e) {
System.err.println("JavaLayerException:");
e.printStackTrace();
}
}
public static void main(String[] args) {
MP3Player mp3Player = new MP3Player(
"C:\\Users\\Athrunwang\\Desktop\\杀死那个石家庄人.mp3");
mp3Player.play();
}
}