web123456

html5 length of time to read web page video

1. The attributes of the html5 <video> element include the duration attribute. Units are seconds. Only support mp4 and ogv formats.

http://www.w3school./html5/html_5_video_dom.asp 

The duration attribute is only available after the video's metadata has been loaded.

2. Video loading event processing

The oncanplaythrough event is executed when the video can be played normally without pause.

/jsref/

3. JS code example

<html>
<body>
<video controls oncanplaythrough="myFunction()">
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video elements.
</source></source></video>

<p ><p>
<script>

var a=("aa");
function myFunction() {

("demo").innerHTML="Video duration: "++"seconds";

}
</script>
</body>
</html>


4、jQueryCode

<video oncanplaythrough="myFunction()"  src="" controls>
</video><br>
                  <p >111</p>
                  <script>             
                     function myFunction() {
                       var a=$("#videoplay").attr("duration");
$("#demo").text("Video duration: "+a+"second");
                     }
                  </script>