White Arrow icon
Back to all Elements

Background Video with Audio (using plyr.js)

An embed video with Mute/UnMute button using plyr.js plugin.

Using an Embed widget we add the html5 video tag and change our video source to the relevant video (I suggest using Google Cloud as a free hosting service for files).

* If you can decode to WEBM format as well, it will have better compatibility.

<video muted autoplay playsinline loop class="video">
 <source src="PLACE_YOUR_VIDEO_URL_HERE" type="video/mp4">
  <source src="PLACE_YOUR_VIDEO_URL_HERE" type="video/webm">
 Your browser does not support the video tag.
</video>

Copy

Now we add the plyr.js library and relevant code:

* this should be added on the page settings under "Before </body> tag"

<script src="https://cdn.plyr.io/3.7.2/plyr.js"></script>

<script>
 document.addEventListener('DOMContentLoaded', () => {
   const controls = [
     'mute',
   ];
   const player = Plyr.setup('.video', { controls, muted: true  });
 });
</script>

Copy

Lastly we need to style the video and the plyr.js buttons. We can do some of that with Webflow elements, by giving them the same classes as the plyr.js plugin uses, and then styling the elements in Webflow.

Other elements need some CSS:

* This can go anywhere, preferably in an Embed widget at the top of the canvas

<style>
 video {
   position: fixed;
   left: 0;
   right: 0;
   top: 0;
   bottom: 0;
   width: 100%;
   height: 100%;
   -webkit-object-fit: cover;
   -moz-object-fit: cover;
   -ms-object-fit: cover;
   object-fit: cover;
 }
 .plyr__control svg {
  width: 40px;
   height: 40px;
   margin-right: 10px;
 }
 .plyr__control span {
  display: none;
 }
</style>

Copy

Preview:

browser mockup
Share:
Heart icon

Destin's Youtube channel Smarter Every Day is one of my favourite places on the web.

Might also interest you:

Dynamic Height

Code
Tricks
JavaScript

A (custom code) solution that combines CSS variables and Vanilla JavaScript for the shrinking / growing of browser top & bottom bars.

Read more
Blue arrow iconWhite Arrow icon

Desktop Grid, Mobile Slider

Cloneable
Tricks
Layout

Change Webflow's Slider to act as a "regular" grid block on desktop, but go back to Slider on Tablet and smaller screens.

Read more
Blue arrow iconWhite Arrow icon

Maintain Form Height on Success

Code
jQuery

Using a little bit of jQuery to adjust the success message height

Read more
Blue arrow iconWhite Arrow icon