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>

猜你喜欢

转载自www.cnblogs.com/mengor/p/9480670.html