Search code examples
javascriptjqueryapirestartvimeo

Restart Vimeo iFrame with Froogaloop JavaScript and jQuery


My page dynamically launches one of several Vimeo iFrame embedded videos and I'm using jQuery to fade them in/out and start/stop. Right now, my close function hides the video and subsequently pauses it. If you bring up the same video after its been hidden it begins from where it was paused the time before. I'd like it to restart. I can't figure out just the right action. Some how "stop" and "restart" aren't options (how illogical is that? play/pause/stop).

I'm linking to Vimeo's hosted version of Froogaloop JS and using jQuery to call the functions.

Thanks!

JavaScript:

$('#close, #underlay').click(function() {
    $('.vim, #close, #container, #underlay').fadeOut(400);
    var player=$f($('.vid:visible')[0]);
    player.api('pause');
});

Solution

  • When you have it fade in, you could seek the video to the beginning like this:

    player.api("seekTo", 0);
    player.play();