//Главный слайдер
var swiperSlider = new Swiper(".sliderSwiper", {
slidesPerView: 1,
loop: true,
centeredSlides: true,
spaceBetween: 20,
speed: 800,
loop: true,
pagination: {
el: ".swiper-pagination",
},
navigation: {
nextEl: ".next-2",
prevEl: ".prev-2",
},
breakpoints: {
320: {
slidesPerView: 1,
spaceBetween: 0
},
480: {
slidesPerView: 1,
spaceBetween: 0
},
640: {
slidesPerView: 1,
spaceBetween: 0
}
}
});
swiperSlider.on('slideChange', function () {
let activeIndex = swiperSlider.realIndex;
//console.log(activeIndex);
$('.swiper-slide').each(function (index, element) {
let videoSlider = $(this).find('.vv')[0];
if (videoSlider) {
videoSlider.pause();
}
});
let r = $('.swiper-slide-active').find('.vv')[0];
console.log(r);
});
<section>
<div class="swiper sliderSwiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="main-slider-block">
<div class="title-slider" data-animate="fadeInUp">ТЕст</div>
<div class="main-slider-img">
<video autoplay="autoplay" class="vv" loop="" muted="" loading="lazy">
<source src="/upload/iblock/e46/ez7vyfl89pngjs9c3sdlt0ays7ntagou.mp4" type="video/mp4">
</video>
</div>
</div>
</div>
<div class="swiper-slide">
<div class="main-slider-block">
<div class="title-slider" data-animate="fadeInUp">ТЕст</div>
<div class="main-slider-img">
<img src="/bitrix/templates/main/img/image.jpg" width="100%">
</div>
</div>
</div>
</div>
<div class="swiper-pagination"></div>
<div class="pagination-arrow gallery-arrow gallery-arrow-lr-0">
<div class="prev-gallery prev-2"></div>
<div class="next-gallery next-2"></div>
</div>
</div>
</section>
мне надо когда фото - остановка всех видео - это я вроде добился
а теперь когда текущий слайд видео - запустить именного его . привязывался к swiper-slide-active но чет не выходит