May 10, 2022
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:

Share:

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

Might also interest you:

3d Video Slider (swiper.js)

Cloneable
CMS
JavaScript

A 3d slider with video items, plays and pauses on click & slide change.

Read more
White Arrow icon

Webflow Dashboard Workspaces Hack

Webflow UI Hack
Code
CSS

Convert the Workspaces dropdown to an open sidebar with custom order.

Read more
White Arrow icon

Glossary

Cloneable
JavaScript
CMS

A clonable for creating an Alphabetical glossary

Read more
White Arrow icon