Published on Sep 22, 2021

How to Stop Background Videos from Looping in Oxygen

Sridhar Katakam

Looking for a way to stop background videos of Sections from looping in Oxygen?

Simply add a Code Block having this JS:

document.addEventListener('DOMContentLoaded', (event) => {
const oxyVideos = document.querySelectorAll(".oxy-video-container video");
oxyVideos.forEach(function(oxyVideo) {
oxyVideo.removeAttribute("loop");
});
})

You may want to change the Code Block’s PHP & HTML to:

<?php
// echo "hello world!";
?>

Before:

After:

References

https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll

https://flaviocopes.com/dom-ready/

https://www.w3schools.com/jsref/met_element_removeattribute.asp

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-ocalendar-check-omagnifiercrossmenuchevron-downarrow-right