Video object property autoPlay in Javascript
The video object property autoPlay used to set and retrieve whether a video should start playing as soon as it is loaded. It specifies that the video should automatically start playing once it is loaded. It returns boolean value true, if the video automatically starts playing, otherwise false.
Syntax
 1 <video>.autoplay // to retrieve
 2 <video>.autoplay = <boolean> // to set
video : A video element object to set and retrieve autoplay property
boolean : It specifies that the video should start playing once loaded

Possible values

1. true : It specifies that the video should start playing once loaded2. false : It specifies that the video should not start playing once loaded
Video property autoplay
 1 <html>
 2 <style>
 3   .container {
 4     margin: 10px 0;
 5   }  
 6 </style>
 7 <body>
 8 	<h1>The Video Object</h1>
 9 	<h2>Example</h2>
 10 	
 11 	<div>
 12 	  <video id="video" width="320" height="240" controls autoplay>
 13 	    <source src="sample.mp4" type="video/mp4">
 14 	    Your browser does not support the video tag.
 15 	  </video>
 16 	</div>
 17 	<p>
 18 	  <button onclick="access()">Access</button>
 19 	</p>
 20 	<p id="result"></p>
 21 	
 22 	<script>
 23 	function access() {
 24 	  const video = document.getElementById("video");	  
 25 	  const str = `Is autoplay enable ? <b>${video.autoplay}</b>`;
 26 	  document.getElementById("result").innerHTML = str;
 27 	}
 28 	</script>
 29 </body>
 30 </html>
Video property autoplay
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us