javascript - When I autoplay an HTML5 video, I can't loop it from a specific point -




i have video want autoplay when page loaded, , loop specific point (16 seconds) when ends. if add "autoplay" in html video doesn't loop @ all. if add "loop" in html video loops disregards eventlistener. if don't add loop or autoplay , play video manually loops @ 16 seconds want to.

how can have video autoplay on page load , loop @ 16 seconds? below code have:

	  document.getelementbyid('video1').addeventlistener('ended', function(){  		this.currenttime = 16;   		this.play();  		}, false);                   
			<video id="video1" width="100%" autoplay  >  			<source src="video1.webm" type="video/webm">			    		  </video>

i managed reproduce problem experienced when had code in head tag rather @ bottom. test worked looked this:

<!doctype html> <html>   <head>     <meta charset="utf-8">     <title>html video</title>   </head>    <body>     <div >         <video id="video1" width="100%" autoplay controls>             <source src="test2.webm" type="video/webm">                    </video>     </div>   </body>   <script>         document.getelementbyid('video1').addeventlistener('ended', function(){                 this.currenttime = 16;                  this.play();         }, false);     </script> </html> 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -