[size=13.3333px]import java.io.BufferedInputStream;
[size=13.3333px]import java.io.FileInputStream;
[size=13.3333px]import javazoom.jl.player.Player;
[size=13.3333px]/**
[size=13.3333px] * @author Brandon B. Lin
[size=13.3333px] * 2013-1-25
[size=13.3333px] */
[size=13.3333px]public class MP3Player {
[size=13.3333px] public MP3Player(String filename) {
[size=13.3333px] this.filename = filename;
[size=13.3333px] }
[size=13.3333px] public void play() {
[size=13.3333px] try {
[size=13.3333px] BufferedInputStream buffer = new BufferedInputStream(
[size=13.3333px] new FileInputStream(filename));
[size=13.3333px] player = new Player(buffer);
[size=13.3333px] player.play();
[size=13.3333px] } catch (Exception e) {
[size=13.3333px] System.out.println(e);
[size=13.3333px] }
[size=13.3333px] }
[size=13.3333px] public static void main(String[] args) {
[size=13.3333px] MP3Player mp3 = new MP3Player("陈瑞 - 白狐.mp3");
[size=13.3333px] mp3.play();
[size=13.3333px] }
[size=13.3333px] private String filename;
[size=13.3333px] private Player player;
[size=13.3333px]}
|
|