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