JavaSwing后台播放音乐mp3
本文为大家分享了用Java来播放mp3的具体代码,使用jl1.0.1.jar,供大家参考,具体内容如下
代码:
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import javazoom.jl.player.Player;
/**
* @author Brandon B. Lin
* 2013-1-25
*/
public class MP3Player {
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 (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) {
MP3Player mp3 = new MP3Player("陈瑞 - 白狐.mp3");
mp3.play();
}
private String filename;
private Player player;
}
以上是 JavaSwing后台播放音乐mp3 的全部内容, 来源链接: utcz.com/z/342291.html