Some notes on Firefox's current media autoplay settings
I am quite violently against videos ever auto-playing in my regular browser, under basically any circumstances ever (including ones like the videos that Twitter uses for those GIFs that people put in their tweets). I hate it with audio, I hate it without audio, I hate it on the web page I'm currently reading, I hate it on the web page in another tab. I just hate it.
I've traditionally used some number of extensions to control this
behavior on prominent offenders like YouTube (in addition to setting
various things to 'ask before activating'). When I wrote about my
switch to Firefox Quantum, I said that I was
experimenting with just turning off Firefox's
preference and it seemed to work. I had to later downgrade that
assessment and tinker with additional preferences, and I have finally
dug into the code to look at things in more depth. So here are some
The actual Firefox code that implements the autoplay policy checks is pretty short and sort of clear; it's the obvious function in AutoplayPolicy.cpp. As far as I can follow the various bits, it goes like this:
media.autoplay.enabledis true (the default case), the autoplay is immediately allowed. If it's false, we don't reject it immediately; instead, we continue on to make further checks and may still allow autoplay. As a result, the preference is misnamed (likely for historical reasons) and should really be called something like
(There is currently no Firefox preference that totally and unconditionally disables autoplay under all circumstances.)
- Pages with WebRTC camera or microphone permissions are allowed to
autoplay, presumably so that your video conferencing site works
media.autoplay.enabled.user-gestures-neededis false (the default), whether autoplay is allowed or forbidden is then based on the video element is 'blessed' or, I think, if the web page is the currently focused web page that's handling user input (ie, it's not hidden off in a tab or something). As far as blessing goes, the code comments for this say:
True if user has called load(), seek() or element has started playing before. It's only use for checking autoplay policy[.]
media.autoplay.enabled.user-gestures-neededis true, Firefox checks to see if the video will be playing without sound. If it will be silent, the video is allowed to autoplay, even if it is not in the current tab and you haven't activated it in any way.
If the video has audio, it's allowed to autoplay if and only if the web page has been activated by what comments call 'specific user gestures', which I think means you clicking something on the web page or typed at it.
This means the behavior of silent videos is different based on
whether or not you have m.a.e.user-gestures-needed set. If it's the
false, a silent video in another tab will not autoplay.
If you've set it to
true to get more control in general, you
paradoxically get less control of silent videos; they'll always
autoplay, even when they've been opened in another tab that you
haven't switched over to yet.
(My current fix for this is to comment out the audio checking portion
of that code in my own personal Firefox build, so that silent videos
get no special allowances. A slightly better one might be to
immediately deny autoplay if EventStateManager::IsHandlingUserInput()
is false, then check audio volume; if I'm understanding the code
right, this would allow silent video to autoplay only on the current
page. Since I don't want videos to ever autoplay, I'm fine with my
fix and I may someday try making the entire function just immediately
media.autoplay.enabled does cause a certain amount of
glitches for me on YouTube, but so far nothing insurmountable;
people have reported more problems with other sites (here is one
Mozilla people are apparently actively working on this area, per
which has quite a number of useful and informative comments (eg), and
(As far as other video sites go, generally I don't have uMatrix set up to allow them to work in the first place so I just turn to my alternate browser. I only have YouTube set up in my main Firefox because I wind up on it so often and it's relatively easy.)