在光滑的旋转木马中,我的视频没有播放或暂停

时间:2018-06-13 05:30:37

标签: javascript slick.js

在这里,我希望当我的光滑滑块暂停时,我的视频也应暂停 错误:$(...)。get(...)。pause不是函数

$('.main-slide').on('afterChange', function(event, slick, currentSlide) {
            
  var vid = $(slick.$slides[currentSlide]).find('.embed-video');
  if (vid.length > 0) {
    $('.main-slide').slick('slickPause');
    $(vid).get(0).pause();
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main-slide">
  <div class="banner-image image slide1">		
    <img src="images/banner.jpg" />		
  </div>
  <div class="banner-image image slide2">		
    <iframe class = "embed-video" id = "theVideo" src="https://www.youtube.com/embed/NsZ2nwWRH5c?rel=0&amp;autoplay=1&amp;controls=0&amp;showinfo=0&amp;enablejsapi=1" frameborder="0" allowfullscreen></iframe>		
  </div>
  <div class="banner-image image slide3">		
    <iframe class = "embed-video" id = "theVideo" src="https://www.youtube.com/embed/NsZ2nwWRH5c?rel=0&amp;autoplay=1&amp;controls=0&amp;showinfo=0&amp;enablejsapi=1" frameborder="0" allowfullscreen></iframe>		
  </div>
</div>

0 个答案:

没有答案