input 上傳視頻文件 獲取 視頻的時長和本地地址


由於業務需求,需要上傳視頻,但是視頻的時長都吃重后台管理和數據庫中手動填寫的。

 

<html

<body

<input type="file" id="file" onchange="onInputFileChange()"

<audio id="audio_id" controls autoplay loop>Your browser can't support HTML5 Audio</audio> 

<script> 

function onInputFileChange() { 

var file = document.getElementById('file').files[0]; 

var url = URL.createObjectURL(file); 

console.log(url); 

var videos =document.getElementById("audio_id")

videos.src = url; 

setTimeout(function(){

if(videos.readyState>0){

var minutes = parseInt(videos.duration / 60, 10);

var seconds = videos.duration % 60;

 

console.log(minutes)

alert(seconds)

 

}

},500)

 

 

}

 

 

 

 

 

</script

</body

</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM