jackmoore / colorbox

A light-weight, customizable lightbox plugin for jQuery
http://www.jacklmoore.com/colorbox/
MIT License
4.75k stars 1.14k forks source link

Autoplay vimeo? #892

Closed miguel-moya closed 3 years ago

miguel-moya commented 3 years ago

I can open a vimeo video inside the modal but the video appears paused. Is it possible that it has autoplay when opening the modal?

jackmoore commented 3 years ago

Hi @miguel-moya, Colorbox is pretty agnostic about content so this is more of a Vimeo and/or browser issue.

I checked Vimeo's documentation about autoplay and put together this example for you:

$.colorbox({
  html: '<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&muted=1" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>'
})

Alternative example:

<a class='vimeo' href="http://player.vimeo.com/video/2285902?autoplay=1&muted=1">Flash / Video (Iframe/Direct Link To Vimeo)</a>
<script>
$(".vimeo").colorbox({iframe:true, innerWidth:500, innerHeight:409});
</script>

Note the inclusion of autoplay=1 and muted=1 in the querystring. The Vimeo documentation link I posted has more details if needed (Chrome refuses autoplay for unmuted videos).