本案例用的swiper-4.2.2.min.js 和 swiper-4.2.2.min.css
html代碼:
<#list videoList as video>
loop : true,
speed : 2000,
autoplay : {
delay : 5000,
stopOnLastSlide : false,
disableOnInteraction : true,
},
pagination : '.swiper-pagination'
})
mySwiper2.el.onmouseover = function() { //鼠標(biāo)進(jìn)入
mySwiper2.autoplay.stop(); //輪播停止
}
mySwiper2.el.onmouseout = function() { //鼠標(biāo)離開(kāi)
var v_len = $("#swiper2 .swiper-slide").find("video").length
for(var i = 0;i $("#swiper2 .swiper-slide").find("video").get(i).pause(); //把所有停止
}
mySwiper2.autoplay.start(); //輪播開(kāi)始
}
$("#swiper2 .swiper-slide video").on("click", function() {
var isPaused = $(this).get(0).paused //視頻是否在播放
if(isPaused){ // 我點(diǎn)擊的這個(gè)是暫停的
$(this).get(0).play(); //播放
}else{
$(this).get(0).pause(); //停止
}
});