Add a button to play or pause the video. Then we have styled the video to a hundred percentage height and width so that it covers the entire background.
The following is the code snippet to set video as a site background in HTML5.
<video autoplay muted loop id = "myVideo"> <source src = "demo.mp4" type = "video/mp4"> Your browser does not support HTML5 video. </video>
The following is to pause the video −
function display() {
if (video.paused) {
video.play();
btn.innerHTML = "Pause the video!";
} else {
video.pause();
btn.innerHTML = "Play";
}
}