dimsemenov / Magnific-Popup

Light and responsive lightbox script with focus on performance.
http://dimsemenov.com/plugins/magnific-popup/
MIT License
11.39k stars 3.48k forks source link

Open video (Magnific Popup) with setTimeout and autoplay #1145

Open juscelinobarao opened 4 years ago

juscelinobarao commented 4 years ago

The code below opens a YouTube video after 5 seconds (perfectly). But I can't make the video play automatically.

<script type="text/javascript">
setTimeout(function(){
      $.magnificPopup.open({
          items: {
              src: 'http://www.youtube.com/watch?v=VZWMLKxV9xo?autoplay=1&rel=0'
          },
          type: 'iframe',
                  preloader: true
      });
 }, 5000);
</script>

Where am I going wrong? Is any necessary parameter missing? What is the best way to do this?

navin09 commented 4 years ago

@juscelinobarao Chrome changed their autoplay policies Muting the audio while embedding seems to work. See: https://codepen.io/navin09/pen/MWeeJjo