File file = new File("C:\\Users\\sf\\Desktop\\7.20\\1705\\1.mp3");
读取本地的资料这种地址可以用,请问各位大神我要读取网上的资料怎么读取,
File file = new File("http:\\sc1.111ttt.com\\2016\\5\\2\\09\\205092225298.mp3");
这样子可以用吗??格式是怎么样的???
String s="http://192.168.3.105:8080/McDonald_WX/file.do?n=Hn_Story/87/285db0f2-a9ff-488b-a580-0bde908693cd.mp3";
URL urlfile = new URL(s);
像这种上传到服务器的音频怎么获取时长呢??求具体代码,谢!本地的和网上的我都已经掌握,并测试OK,但是像这种上传到服务器上面的音频还真不知道怎么获取它的时长。
@1705:
import java.io.BufferedInputStream; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import javazoom.jl.decoder.Bitstream; import javazoom.jl.decoder.BitstreamException; import javazoom.jl.decoder.Header; public class Test { public static void main(String[] args) throws IOException, BitstreamException { URL urlfile = new URL("http://sc1.111ttt.com/2015/1/06/06/99060941326.mp3"); URLConnection con = null; try { con = urlfile.openConnection(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } int b = con.getContentLength();// BufferedInputStream bis = new BufferedInputStream(con.getInputStream()); Bitstream bt = new Bitstream(bis); Header h = bt.readFrame(); int time = (int) h.total_ms(b); System.out.println(time / 1000); } }
@与阳光握手言和: File file = new File("WX\\Hn_Story\\87285db0f2-a9ff-488b-a580-0bde908693cd.mp3");
那如果是我把一个音频文件上传到了WX项目的Hn_Story文件夹,我想取这个音频的时长,第一行应该怎么写??谢谢!!
File file = new File("WX\\Hn_Story\\87285db0f2-a9ff-488b-a580-0bde908693cd.mp3");???
@1705:
File file = new File("wx\\Hn_Story\\*****.mp3"); try { MP3File f = (MP3File)AudioFileIO.read(file); MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader(); System.out.println(audioHeader.getTrackLength()); } catch(Exception e) { e.printStackTrace(); }
@与阳光握手言和: