Pause Vimeo universal embed when hidden using jQuery

Spread the love

Question Description

I have a Vimeo video (via universal embed iframe) hidden on my page. Clicking a link fades it in, and clicking outside of the video (lightbox-style) fades it out and hides it – but the video keeps playing. I read on Vimeo’s API that you can use JSON objects to pause the video, but I don’t understand what they’re saying.

HTML:



JavaScript:

$('#underlay').click(function() {
    //pause VISIBLE (there are multiple) Vimeo video via API
    $('.vim, #underlay').fadeOut(400);
});

Practice As Follows

You need to add from one of the froogaloop libraries.

JS

player=$f(document.getElementById('tide'));// you can use jquery too: $('#tide')[0] 
player.api('pause');

Annoyingly simple. Here’s an example on jsfiddle.net.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.