<script src="https://player.vimeo.com/api/player.js"></script>
<script>
var swiper = new Swiper('.swiper-container', {
loop: true,
effect: 'fade',
pagination: {
el: '.swiper-pagination',
type: 'fraction',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
on: {
slideChangeTransitionStart: function () {
var iframe = document.querySelector('.swiper-slide-active iframe');
var player = new Vimeo.Player(iframe);
player.play().then(function() {
console.log('play success');
}).catch(function(error) {
console.log('play failed');
});
var iframe2 = document.querySelectorAll('.swiper-wrapper .swiper-slide:not(.swiper-slide-active) iframe');
for (var i=0; i<iframe2.length; i++) {
var player = new Vimeo.Player(iframe2[i]);
player.unload().then(function() {
console.log('unload success');
}).catch(function(error) {
console.log('unload failed');
});
}
},
}
});
</script>