Skip to content

Instantly share code, notes, and snippets.

@jessedc
Last active June 17, 2018 20:59

Revisions

  1. jessedc revised this gist Apr 10, 2013. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions vimeo-js-api.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <html>
    <head></head>
    <body>
    <!-- NOTE: ?api=1 and player_id at the end of the URL -->
    <iframe id="player" width="" height="" src="http://player.vimeo.com/video/62207569?api=1&player_id=player" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

    <script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>

    <script>
    var player = $f(document.getElementById('player'));
    player.addEvent('ready', function() {
    player.api('play');
    });
    </script>
    </body>
    </html>
  2. jessedc revised this gist Apr 9, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vimeo.html
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@
    //finds the 'play' button within the Vimeo iframe
    function iFrameButton() {
    //window.frames[0].document.getElementsByTagName('div')[1]; // this also works
    return window.frames[0].document.getElementsByTagName('div')[1];//window.frames[0].document.getElementsByTagName('button')[5];
    return window.frames[0].document.getElementsByTagName('button')[5];
    }

    //simple boolean condition to check for the iframe button
  3. jessedc created this gist Apr 9, 2013.
    45 changes: 45 additions & 0 deletions vimeo.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    <html>
    <head></head>
    <body>
    <iframe width="" height="" src="http://player.vimeo.com/video/62207569 " frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
    <script>

    //NOTE: Jesse Collis github.com/jessedc - this works as of it's last updated date. YMMV

    // Add a listener for the window's load event
    window.addEventListener('load', onWindowLoad, false);

    function onWindowLoad(event) {
    //use a loop to continue checking the vimeo iframe for the 'play' button
    checkForTrue(isIframeButtonLoaded, iFrameButtonLoaded);
    }

    function checkForTrue(func, callback) {
    setTimeout(function() {
    if (func()) {
    callback( iFrameButton() );
    } else {
    checkForTrue(func, callback);
    };
    }, 1000);
    }

    //finds the 'play' button within the Vimeo iframe
    function iFrameButton() {
    //window.frames[0].document.getElementsByTagName('div')[1]; // this also works
    return window.frames[0].document.getElementsByTagName('div')[1];//window.frames[0].document.getElementsByTagName('button')[5];
    }

    //simple boolean condition to check for the iframe button
    function isIframeButtonLoaded() {
    return ( iFrameButton() != null );
    }

    //once the button is loaded, click it
    function iFrameButtonLoaded(iFrameButton) {
    iFrameButton.click();
    }

    </script>
    </body>
    </html>