wangjienull

博客园 首页 新随笔 联系 订阅 管理

由于业务需求,需要上传视频,但是视频的时长都吃重后台管理和数据库中手动填写的。

 

<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>

 

posted on 2017-02-07 23:06  wangjienull  阅读(4353)  评论(0)    收藏  举报