How to run Vimeo video automatically (with autoplay)

Asked

Viewed 5,810 times

2

You can start a video automatically when you open in a lightbox?

When clicked, open a lightbox with the VIMEO video, only I want it started when opening the link and not when you click on play.

I put the iframe q the VIMEO offers and put, but it does not work. I also tried at the end of the link the function ?autoplay=1 also doesn’t work.

  • try to see this topic: https://vimeo.com/forums/topic:1506

2 answers

2

I don’t know which bookstore you’re using for Lightbox, but with the fancybox even has an example with Vimeo and the video starts soon.

Live code: http://jsbin.com/qepeme/1/edit?html,js,output

HTML:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
    <!-- Add jQuery library -->
  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

  <!-- Add mousewheel plugin (this is optional) -->
  <script type="text/javascript" src="http://fancyapps.com/fancybox/lib/jquery.mousewheel-3.0.6.pack.js"></script>

  <!-- Add fancyBox -->
  <link rel="stylesheet" href="http://fancyapps.com/fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
  <script type="text/javascript" src="http://fancyapps.com/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  <!-- Optionally add helpers - button, thumbnail and/or media -->
  <link rel="stylesheet" href="http://fancyapps.com/fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.5" type="text/css" media="screen" />
  <script type="text/javascript" src="http://fancyapps.com/fancybox/source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>
  <script type="text/javascript" src="http://fancyapps.com/fancybox/source/helpers/jquery.fancybox-media.js?v=1.0.6"></script>
</head>
<body>

  <ul>
    <li><a class="fancybox-media" href="http://www.youtube.com/watch?v=opj24KnzrWo">Youtube</a></li>    
    <li><a class="fancybox-media" href="http://vimeo.com/36031564">Vimeo</a></li>
  </ul>

</body>
</html>

Javascript:

$(document).ready(function() {
  $('.fancybox-media').fancybox({
    openEffect  : 'none',
    closeEffect : 'none',
    helpers : {
      media : {}
    }
  });
});
  • Thanks for the help! I was able to solve it like this: Find the following code in the folder where Nivo-lightbox.min.js is. http://player.vimeo.com/video/"+o[3] Then replace it with the following. http://player.vimeo.com/video/"+o[3]+'? autoplay=1 ';

2


Note: At the moment (08/19/205) the player is generating a script error when you select the trailer videos (in the other videos is normal), the error is as follows:

Uncaught Referenceerror: Numberutility is not defined - share2_combined.min.js? 34123595:1

At the time of selecting the video in embed you should click on + Show options, as in the image:

inserir a descrição da imagem aqui

This will appear, in it select the autoplay:

inserir a descrição da imagem aqui

The code should look like this:

<iframe src="https://player.vimeo.com/video/75187319?autoplay=1&title=0&byline=0&portrait=0" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

And the URL should look like this https://player.vimeo.com/video/75187319?autoplay=1&title=0&byline=0&portrait=0

Note: I recommend using html &amp; instead of &, although Html5 normally accepts the & without the amp; you may still have a number of eventual problems, for example if you hear an SVG on your page or something relating to XML.

Note that if autoplay is not occurring it may be a matter of sandbox in your lightbox that uses iframes.

To complement the answer of @balexander, you must use the class fancybox.iframe within the attribute class="", should look like this:

<!DOCTYPE html>
<html>
<head>
    <title>Exemplo</title>

    <!-- Adiciona biblioteca jQuery -->
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

    <!-- Adiciona FancyBox -->
    <link rel="stylesheet" href="/fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
    <script type="text/javascript" src="/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
    <script>
    $(document).ready(function() {
        $(".fancybox-media").fancybox({
            maxWidth    : 800,
            maxHeight   : 600,
            fitToView   : false,
            width       : '70%',
            height      : '70%',
            autoSize    : false,
            closeClick  : false,
            openEffect  : 'none',
            closeEffect : 'none'
        });
    });
    </script>
</head>
<body>
    <a class="fancybox-media fancybox.iframe" href="https://player.vimeo.com/video/75187319?autoplay=1&amp;title=0&amp;byline=0&amp;portrait=0">Play</a>
</body>
</html>

Using Nivo-Lightbox:

It should look like this (requires version 1.2.0), download the files from https://github.com/gilbitron/nivo-lightbox

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="nivo-lightbox.css" type="text/css" />
    <link rel="stylesheet" href="themes/default/default.css" type="text/css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script src="nivo-lightbox.min.js"></script>
    <script>
    $(document).ready(function(){
        $('a').nivoLightbox();
    });
    </script>
</head>
<body>
    <a href="https://player.vimeo.com/video/75187319?autoplay=1&amp;title=0&amp;byline=0&amp;portrait=0" data-lightbox-type="iframe">Carregar video</a>
</body>
</html>
  • The library that and use is nivoLightbox. Is it possible to add? Thanks for the help William =D

  • @mdesigner edited the answer :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.