javascriptvimeofroogaloopvimeo-player

Reset Vimeo player when finished


How can I reset an embed Vimeo video to how it was onload after it's done playing?

The Vimeo API offers an unload method

player.api("unload")

But it isn't working for non-flash players.


Solution

  • Using the Vimeo API, you can add an event for finish to trigger the reload. The Vimeo API includes a method unload(), but it isn't supported in HTML players. Instead, reset the URL in the iframe to return the video to it's original state.

    HTML

    <iframe src="//player.vimeo.com/video/77984632?api=1" id="video"></iframe>
    

    JS

    var iframe = document.getElementById("video"),
        player = $f(iframe);
    
    player.addEvent("ready", function() {        
        player.addEvent('finish', function() {
            player.element.src = player.element.src;
        });
    });