athrunwang

纪元
数据加载中……
java播放mp3
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();
}
}

posted on 2013-01-28 16:57 AthrunWang 阅读(561) 评论(1)  编辑  收藏

评论

# re: java播放mp3 2013-12-09 15:15 vh

怎么暂停?close直接就关掉了
  回复  更多评论    

只有注册用户登录后才能发表评论。


网站导航: