zoukankan      html  css  js  c++  java
  • 选择本地视频时获取视频分辨率和时长

    < video style = "display:none;" controls = "controls" id = "aa" > </video> 
    <input type = "file" onchange = "changeFile(this)" >
    <script>
      function myFunction(ele) {
        //视频时长  单位秒
        alert(Math.floor(ele.duration))
      }
      document.querySelector('#aa').addEventListener('canplaythrough', (ret) => {
        if (ret.path && ret.path[0].duration) {
          console.log(ret.path[0].duration)
        } else if (ret.target && ret.target.duration) {
          console.log(ret.target.duration)
        }
      })
    function changeFile(ele) {
      var video = ele.files[0];
      var url = URL.createObjectURL(video);
      console.log(url);
      document.getElementById("aa").src = url;
    </script>
  • 相关阅读:
    MongoDB Shell
    mongo 日记
    java 堆栈 静态
    面向对象(2)
    面向对象(1)
    mongo 学习笔记
    深入浅出学Spring Data JPA
    java记录
    mongodb 2.6 window 安装启动服务
    CF1012F Passports
  • 原文地址:https://www.cnblogs.com/zhangrenjie/p/11847122.html
Copyright © 2011-2022 走看看