title: how to show magnific-popup when youtube video finish
body: <p>i need to show a popup   when youtube video finish it works fine for the alert() but when i tried to make magnific popup instead if the alert it dosen't work here is my code</p>
  
  
  
  <pre><code>&lt;script&gt;
      // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');
  
      tag.src = 'https://www.youtube.com/iframe_api';
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
      // 3. This function creates an &lt;iframe&gt; (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubeIframeAPIReady() {
          player = new YT.Player('player', {
          height: '600',
          width: '600',
          videoId: 'id',
          playerVars: { 'autoplay':"0", 'controls':"1" },
          events: {
              'onReady': onPlayerReady,
              'onStateChange': onPlayerStateChange
          }
          });
      }
  
      var playerReady = false;
      function onPlayerReady(event) {
          playerReady = true;
      }
      function onPlayerStateChange(event) {
          if (event.data == YT.PlayerState.ENDED ) {            
  
    $.magnificPopup.open({
          items: {
              src: 'mylink to the pic'
          },
          type: 'image'
  
        // You may add options here, they're exactly the same as for $.fn.magnificPopup call
        // Note that some settings that rely on click event (like disableOn or midClick) will not work here
      }, 0);  }
      }
  &lt;/script&gt;
  </code></pre>