/*** 获取读音时长 单位:s* @param mp3Url* @return* @throws IOException* @throws Exception*/
public static int ReadMp3(String mp3Url) throws IOException, Exception {URL url = new URL(mp3Url);URLConnection con = null;try {con = url.openConnection();} catch (IOException e) {e.printStackTrace();}BufferedInputStream bis = new InputStream());Bitstream bt = new Bitstream(bis);//获取mp3时间长度Header header = bt.readFrame();int mp3Length = ContentLength();int time = (int) al_ms(mp3Length);return time / 1000;
}
当url存在特殊符号或空格时InputStream()会出现java.io.IOException: Server returned HTTP response code: 400 for URL,需要用de(url, "UTF-8")进行转义,默认转义空格为“+”,需要用url = placeAll("+", "%20")替换为%20
<dependency><groupId>com.badlogicgames.jlayer</groupId><artifactId>jlayer</artifactId><version>1.0.2-gdx</version></dependency>
本文发布于:2024-01-28 00:55:49,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17063745513681.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |