Autoplay vimeo webflow

Ive been battling to get autoplay to work on a video modal using a Vimeo video.

I have tracked it down to being a Chrome specific and Vimeo specific issue. You can see in the live link below that the video plays for 1s then pauses itself.

Live link shows issue with Vimeo DOES NOT autoplay:
[//vimeo-autoplay.webflow.io/][//Live Link]

[Webflow - vimeo-autoplay][//Read only link]

My solution:

Since I needed a solution I persisted and found a solution in case anyone else runs into the same issue.

This is using click events to play the video when a Modal opens and pauses it when it is closed.

However I could not get this to work with the Webflow video element. I ended up adding it into an HTML embed

eg:

The Video ID I put straight on the embed

var video = document.getElementById["video"]; $[document].ready[function[] { $["#closeModal"].click[function[]{ var iframe = video.getElementsByTagName["iframe"][0].contentWindow; iframe.postMessage['{"method":"pause"}', '*']; }]; }]; $[document].ready[function[] { $["#openModal"].click[function[]{ var iframe = video.getElementsByTagName["iframe"][0].contentWindow; iframe.postMessage['{"method":"play"}', '*']; }]; }];

Video liên quan

Chủ Đề