Is autoplaying a muted background video possible?

I get an error message when trying to autoplay a muted background video using the html5 video tag

Autoplay is only allowed when approved by the user, the site is activated by the user, or media is muted. video-github-03.html

I have used to muted parameter but still it refuses to autoplay, any ideas ?

<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
  margin: 0;
}

#backgroundVideo {
  position: fixed;
  right: 0;
  bottom: 0;
  min-width: 100%; 
  min-height: 100%;
}
</style>
</head>
<body>
<video autoplay muted loop id='backgroundVideo'>
<source src='https://github.com/LoveBug2084/test/raw/refs/heads/main/arnold.mp4' type='video/mp4'>
Your browser does not support HTML5 video.
</video>
</body>
</html>

What web browser and kind of device are you using? I put your code in an HTML file and uploaded it to my InfinityFree hosting account, and then tried it in both Opera GX and Firefox. In both of them the video autoplays like it should (even with no controls) and it’s muted like it should be.
If you know your web browser supports it, I’d recommend checking for any settings to block content from being autoplayed or maybe even any browser extensions/plugins that disable autoplay.

6 Likes

oh thats interesting, I’m using librewolf (branch of firefox)

I’ll investigate thanks

for me it doesn’t work at all, it must be a setting in librewolf

https://zoltar.eu.org/code/video-github/video-github-02.html

@EdwardHamHam :heart: found it, in
settings → privacy & security → permissions → autoplay

the default setting is block audio & video
i changed the default to block audio

I guess the firefox default here differs to librewolf’s
thanks for pointing me in the right direction :+1:

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.