直接代码
public class ReadMp3 {
private String _songName;
ReadMp3(String songName) throws IOException, Exception{
_songName = songName;
URL url = new URL("http://fs.w.kugou.com/201901082013/9ec2463ebd15378341c24d982ccf183f/G009/M00/16/13/SQ0DAFUWmN-ALX4LADv-LPZ8GHs526.mp3");
URLConnection con = null;
try{
con = url.openConnection();
}catch(IOException e){
e.printStackTrace();
}
BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
Bitstream bt = new Bitstream(bis);
//获取mp3时间长度
Header header = bt.readFrame();
int mp3Length = con.getContentLength();
int time = (int) header.total_ms(mp3Length);
System.out.println(time / 1000);
Player player = new Player(bis);
player.play();
}
public static void main(String[] args) throws Exception{
ReadMp3 mp3 = new ReadMp3("贝加尔湖畔");
}
}