2

I have a jQuery slider (mostly identical to the http://slidesjs.com one). I haven't had luck finding an answer to the question of how to pause the "current" or visible slide's YouTube video when the "next" or "previous" button is pressed while also changing the slide itself. I'm using YouTube's iFrames instead of the old embed code, too.

Is there a way to achieve this function with the iFrames? I know that the Anything Slider ( http://css-tricks.com/anythingslider-jquery-plugin/ ) boasts the ability to stop videos, but I'm not sure how it's achieved.

This sounded like it would work, but I'm not sure how to tie it in with an event to set off the video pause function.

Any help would be greatly appreciated.

Community
  • 1
  • 1
Nick
  • 451
  • 1
  • 8
  • 16
  • You need to integrate youtube api with anythingslider. http://code.google.com/intl/tr-TR/apis/youtube/overview.html – Salt Hareket Dec 24 '11 at 22:13
  • @salt I believe the YouTube API is already built into Anything Slider. However, I'm trying to do it separately on a slider based off of the slidesjs.com slider. I've seen the API pages already. – Nick Dec 25 '11 at 00:58

2 Answers2

2

You need to enable JS API for your player.

After that you can use player.pauseVideo() to pause the video.

Martti Laine
  • 12,655
  • 22
  • 68
  • 102
0
$('iframe').each(function(i,e){
    let iframeSrc = $(e).attr('src');
    $(e).attr('src',iframeSrc);
});

This will reset src for all videos, you can modify it to target only one

let iframeSrc = $('.youtube_video').attr('src');
$('.youtube_video').attr('src',iframeSrc);

Replace the class '.youtube_video' with your actual iframe class