获取音频文件的时间

  function geTime(ele) {
     
	var hour = parseInt((ele.duration)/3600);
	var minute = parseInt((ele.duration%3600)/60);
	var second = Math.ceil(ele.duration%60);
	console.log("这段视频的时长为:"+hour+"小时,"+minute+"分,"+second+"秒");
}  
 
function changeFile(ele){
       
    var video = ele.files[0];  
    var url = URL.createObjectURL(video);  
    console.log(url);  
    document.getElementById("videoData").src = url;  
} 

<video style="display:none;" controls="controls" id="videoData" oncanplaythrough="geTime(this)"></video>
    <input type="file" onchange="changeFile(this)" />

**
**

你可能感兴趣的:(音频文件时间)