1. 程式人生 > >js獲取視訊時長

js獲取視訊時長

<!DOCTYPE html>  
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
    <title>無標題文件</title>  
    </head>  

    <body>  
    <p>  
	<video src="578df5e1e6953.mp4" controls preload="auto" id="player"></video>
    </p>  
    <input name="submit" type="submit" onclick="getInfo()">  
    <p>  

    <script language="javascript">  
     var time;  
      function getInfo(){  
      var pl=document.getElementById("player");  
	  time = pl.duration;
       alert(time);
     }  
    </script>  
    </p>  
    </body>  
    </html>  

注意:不支援視訊預載入的瀏覽器不支援此方式