0

Possible Duplicate:
How to pause a YouTube player when hiding the iframe?

I have a jquery accordion which plays youtube videos. How can I stop the youtube video from playing when I close the layer? It keeps on playing in the background.

I think I just have to add something tiny to the code but am completely puzzled unfortunately.

Here is my example and the code: http://defroster.99k.org/youtube_div.htm

Thanks a million for help! Marcus

Community
  • 1
  • 1
Marcus Silverman
  • 243
  • 1
  • 7
  • 22
  • 1
    this [answer](http://stackoverflow.com/questions/2128535/stop-a-youtube-video-with-jquery) should help. – effectica Aug 10 '12 at 15:13

2 Answers2

1
$("#the-accordion").accordion({
    changestart: function(){
        player.stopVideo();
    }
});
Vic
  • 8,261
  • 6
  • 42
  • 55
1

Try this:

$(document).ready(function(){
    $(".accordion2 h3").eq(40).addClass("active");
    $(".accordion2 p").eq(40).show();
    $(".accordion2 h3").click(function(){
        var video = $(".accordion2 h3.active").next().children();
        var src = video.attr("src");
        video.attr("src","");
        video.attr("src",src);
        $(this).next("p").slideToggle("slow")
        .siblings("p:visible").slideUp("slow");
        $(this).toggleClass("active");
        $(this).siblings("h3").removeClass("active");
    });
});​

Example here: http://jsfiddle.net/r8h7t/20/

Vic
  • 8,261
  • 6
  • 42
  • 55