JavaSwing后台播放音乐mp3
本文为大家分享了用Java来播放mp3的具体代码,使用jl1.0.1.jar,供大家参考,具体内容如下
代码:
importjava.io.BufferedInputStream; importjava.io.FileInputStream; importjavazoom.jl.player.Player; /** *@authorBrandonB.Lin *2013-1-25 */ publicclassMP3Player{ publicMP3Player(Stringfilename){ this.filename=filename; } publicvoidplay(){ try{ BufferedInputStreambuffer=newBufferedInputStream( newFileInputStream(filename)); player=newPlayer(buffer); player.play(); }catch(Exceptione){ System.out.println(e); } } publicstaticvoidmain(String[]args){ MP3Playermp3=newMP3Player("陈瑞-白狐.mp3"); mp3.play(); } privateStringfilename; privatePlayerplayer; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。