Js monitors video playback events and prints logs. js monitors video playback logs.

Source: Internet
Author: User

Js monitors video playback events and prints logs. js monitors video playback logs.

Html code:

 1 <!DOCTYPE html> 2 

 

Js Code:

1 <script type = "text/javascript"> 2 window. addEventListener ("load", getVideoEvent); 3 function getVideoEvent () {4 var videoes = document. getElementsByTagName ("video"); 5 for (var I = 0; I <videoes. length; I ++) {6 showEventLog ("video" + (I + 1), videoes [I]); 7} 8} 9 10 function showEventLog (videoNum, Media) {11 eventTester = function (e) {12 Media. addEventListener (e, function () {13 console. log (videoNum + ":" + e); 14}); 15} 16 eventTester ("loadstart"); // The client starts to request data 17 eventTester ("progress "); // The client is requesting data 18 eventTester ("suspend"); // The client proactively terminates the download (not due to an error ), 20 eventTester ("error"); // error 21 eventTester ("stalled") during data request; // eventTester 22 ("play"); // play () and trigger 23 eventTester ("pause") When autoplay starts playing; // pause () trigger 24 eventTester ("loadedmetadata "); // The resource length is 25 eventTester ("loadeddata"); // 26 eventTester ("waiting"); // wait for data, not error 27 eventTester ("playing "); // start playing back 28 eventTester ("canplay"); // you can play back the video, but 29 eventTester ("canplaythrough") may be paused due to loading; // you can play back the video, 30 eventTester ("seeking"); // search for 31 eventTester ("seeked"); // 32 eventTester ("timeupdate "); // change the playback time to 33 eventTester ("ended"); // play end 34 eventTester ("ratechange"); // change the playback speed to 35 eventTester ("durationchange "); // resource Length Change 36 eventTester ("volumechange"); // volume change 37} 38 </script>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.