jQuery how to stop Vimeo video when click

test picture test · May 1, 2012 · Viewed 34.7k times · Source

here is the simple code: http://jsfiddle.net/YAFuW/1/

basicly i tried to use like this:

<iframe src="http://player.vimeo.com/video/40977539?api=1" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

<a href="#">STOP</a>

$('a').click(function() {
   alert('stoped');
   froogaloop.api('unload');
});

Answer

Fresheyeball picture Fresheyeball · May 1, 2012

I don't know a "good" or "right" way to accomplish this cross-browser.
Youtube's JavaScript API fails, too.

But this method is reliable and does work.
Basically, it kills the <iframe> and rebuilds it.

$('a').click(function() {
  alert('stoped');
  vimeoWrap = $('#vimeoWrap');
  vimeoWrap.html(vimeoWrap.html());
});

View at JSFiddle