JS monitors video playback events and prints log

Source: Internet
Author: User

HTML code:

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">5 <title>Multi Source</title>6 </Head>7 <Body>8 <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video>9 <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video>Ten <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> One <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> A <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> - <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> - <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> the <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> - <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> - <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> - <Videosrc= "Http://www.w3school.com.cn/i/movie.mp4"Controls AutoPlay></Video> + </Body> - </HTML>

JS Code:

1<script type= "Text/javascript" >2Window.addeventlistener ("Load", getvideoevent);3 functiongetvideoevent () {4 varVideoes=document.getelementsbytagname ("Video");5  for(vari = 0; i < videoes.length; i++) {6Showeventlog ("video" + (i+1), videoes[i]);7 }8 }9 Ten functionShoweventlog (videonum,media) { OneEventtester =function(e) { AMedia.addeventlistener (E,function(){ -Console.log (videonum+ ":" +e); - }); the } -Eventtester ("Loadstart");//The client begins to request data -Eventtester ("Progress");//client is requesting data -Eventtester ("suspend");//Delayed Download +Eventtester ("Abort");//the client actively terminates the download (not due to an error), -Eventtester ("error");//error encountered while requesting data +Eventtester ("stalled");//Speed Stall AEventtester ("Play");//triggers when play () and AutoPlay start playing atEventtester ("pause");//pause () trigger -Eventtester ("Loadedmetadata");//successful acquisition of resource length -Eventtester ("Loadeddata");// -Eventtester ("Waiting");//wait for data, not error -Eventtester ("playing");//Start Playback -Eventtester ("Canplay");//can be played, but may be paused halfway through loading inEventtester ("Canplaythrough");//can play, the songs are all loaded -Eventtester ("seeking");//Find in toEventtester ("seeked");//Search Complete +Eventtester ("Timeupdate");//Play time Change -Eventtester ("ended");//Play End theEventtester ("Ratechange");//Playback Rate Change *Eventtester ("Durationchange");//Resource Length Change $Eventtester ("Volumechange");//Volume ChangePanax Notoginseng } -</script>

JS monitors video playback events and prints log

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.