title: How to pause youtube video on slide change?
body: <p>I am trying to pause a youtube video when a slide changes using <a href="https://idangero.us/swiper/api/#events" rel="nofollow noreferrer">swiper from iDangerous</a></p>
  
  <p>I have the youtube video urls ending with <code>enablejsapi=1</code> and here is some code, the important part being <code>slideChange</code>:</p>
  
  <pre><code>var swiper_video = new Swiper('.swiper-video', {
  
      loop: true,
      autoplay: false,
      pagination: {
        el: '.swiper-pagination',
      },
      navigation: {
        nextEl: '.swiper-button-next.video-swiper',
        prevEl: '.swiper-button-prev.video-swiper',
      },
      slideChange: function (el) {
        console.log('1');
        $('.swiper-slide').each(function () {
          var youtubePlayer = $(this).find('iframe').get(0);
          if (youtubePlayer) {
            youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
          }
        });
      },
    });
  </code></pre>
  
  <p>Can't seem to get the event to even fire, but I think the rest of the code should work.</p>