js实现视频本地预览,以及获取播放时长

<video style="display:none;" controls="controls" id="aa" oncanplaythrough="myFunction(this)"></video>
<input type="file" onchange="changeFile(this)" >
<script>
    function myFunction(ele) {
     //视频时长 单位秒 alert(Math
.floor(ele.duration)); } function changeFile(ele){ var video = ele.files[0]; var url = URL.createObjectURL(video); console.log(url); document.getElementById("aa").src=url; } </script>

 

posted @ 2018-08-15 12:10  za_szybko  阅读(10166)  评论(0编辑  收藏  举报