JDC*_*v87 5 html video jquery autoplay slick.js
我正在使用从http://kenwheeler.github.io/slick/下载的光滑滑块
我有许多自动播放图像正确显示,但是,我还有一个无法自动播放的 mp4 文件。这是我的 HTML:
<section class="regular slider" style="width: 900px; left: 60px; top: 230px;">
<div>
<video autoplay>
<source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4">
</video>
</div>
<div>
<img src="https://placehold.it/350x300?text=2">
</div>
<div>
<img src="https://placehold.it/350x300?text=3">
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
这是我的脚本:
<script type="text/javascript">
$(document).on('ready', function() {
$(".regular").slick({
dots: true,
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
小智 0
I quote @AsafDavid. Look at the working code example in the original answer.
Yes it can be done using JavaScript. When the video slide becomes the
currentSlideyou have to:
- pause the slider
- play the video
You can do this using the
afterChangeevent:Run Code Online (Sandbox Code Playgroud)$('.sliderMain').on('afterChange', function(event, slick, currentSlide){ if (currentSlide == 5) { $('.sliderMain').slick('slickPause'); myVideo.play(); } });