// This is how you pause a YouTube video on slide change. let $slider = new Swiper($sliderWrapper, { on: { slideChange: function (el) { $('.swiper-slide').each(function () { // Find the YouTube iframe. var youtubePlayer = $(this).find('iframe').get(0); if (youtubePlayer) { // Attempt to send a command to the player to stop the playing of the video. youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); } }); } });