How do I turn off auto play

maahd picture maahd · Jul 15, 2015 · Viewed 17.8k times · Source

I have a .mp4 video embedded in an iframe tag. I can't figure out how to turn off auto play. I tried everything: autoplay="false", autoplay="0", autoplay='false', autoplay='0' but nothing seems to work. Here's my code:

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item behind" src='videos/cloud_computing.mp4' width='640' height='360' style='width:640px;height:360px;'></iframe>
</div>

Before this there was a YouTube video (that didn't auto play) and the code looked like this:

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item behind" src='https://www.youtube.com/embed/v1uyQZNg2vE?enablejsapi=1&amp;html5=1&amp;hd=1&amp;wmode=transparent&amp;controls=1&amp;showinfo=0;rel=0;' width='640' height='360' style='width:640px;height:360px;'></iframe>
</div>

Answer

Josh Stevens picture Josh Stevens · Jul 15, 2015

you need to put a <video> tag round it as it does not know the iframe is a video therefore autoplay will never work. Try the below code.

   <div class="embed-responsive embed-responsive-16by9">
          <iframe class="embed-responsive-item behind"> 
           <video src='videos/cloud_computing.mp4'
             width='640' height='360' style='width:640px;height:360px;' autoplay="0">
            </video>
        </iframe>
        </div>

Note

i would use autoplay="0" and autoplay="1" as chrome does not recognise autoplay="true" or autoplay="false".