Disable autostart/autoplay HTML5 video tag

79 Likes Comment

How to change autoplay off?

Just a simple javascript will help you to disable autoplay feature of video tag in HTML5

<video src="video.mp4" preload="metadata" controls="controls" id="mediaVideo_007" poster="video-poster.jpg"></video>
<script >
  var vid = document.getElementById("mediaVideo_007");
  vid.volume = 0.50;
  $('#mediaVideo_007').click(function() {
  $('#mediaVideo_007').get(0).play()
});	
</script>
  • Remember to remove autoplay param from video tag
  • Set and unique class id of video
  • Make sure the video file, video url play normally.

You might like

About the Author: Toc Xoan

Leave a Reply

Your email address will not be published. Required fields are marked *