Some notes on Firefox's media autoplay settings as of Firefox 89

June 14, 2021

Back in 2018 I wrote about Firefox's media autoplay settings as of Firefox 63. Unsurprisingly, things have changed in the Firefox world since then, and for once they've changed for the better, at least from my perspective. My interest is in basically never having video autoplay. And when I say basically never, I mean it. In particular, I don't want Youtube to autoplay the next video in a playlist or the like.

The basic control for media autoplaying (for video and audio) is in Preferences → Privacy & Security, as covered in Allow or block media autoplay in Firefox. As mentioned there, if you want to block all videos you want 'block audio and video', not just 'block audio', which only blocks videos with un-muted audio and still allows silent ones to autoplay if they want to. This appears to affect everything, including bare video content such as direct links to .mp4s, which is a change from 2018. The limitation of this setting is that by itself, once you click to play a video in a tab, (auto)playing stays enabled until you close the tab again. So once you've let the first Youtube video play, Youtube (or anywhere else) will autoplay as much else as it wants to (in that tab). I prefer to specifically play each video.

To get more control, we need to turn to about:config and its collection of media.autoplay.* settings. Two resources are handy for this; the Firefox source code file AutoplayPolicy.cpp (which has been moved around in the Firefox source tree since 2018) and an additional commentary for media.autoplay.blocking_policy in StaticPrefList.yaml (via this Reddit question and answer).

The Privacy & Security setting controls media.autoplay.default. A setting of 0 means 'allow', 1 means 'block audio (including video with audio)', and 5 means 'block audio and video'. Once you've played video, the media.autoplay.blocking_policy preference controls what happens to future attempts to autoplay video in the same tab. A setting of 0 (the default) allows this to work, so Youtube gets to autoplay further videos. This is apparently called sticky activation. A setting of 1 is called transient activation, and apparently will only autoplay future videos within a narrow time window controlled by dom.user_activation.transient.timeout, which defaults to five seconds. Finally, a setting of 2 appears to always require user input, and it certainly stops Youtube autoplaying the next video for me. It's possible that a setting of 2 will break some sites, and you'll need '1' instead.

(This apparently replaces the old media.autoplay.enabled.user-gestures-needed setting. For a long discussion, see bug 1509933.)

Unfortunately, WebAudio seems to be another matter. Right now, in a normal Firefox the only way to disable WebAudio autoplaying seems to be to have media.autoplay.blocking_policy left at the default of 0 and media.autoplay.block-webaudio set to true. If you set another value for media.autoplay.blocking_policy, WebAudio can always autoplay if it wants to regardless of other settings. This may be something that Firefox would consider a bug. Fortunately WebAudio seems to be relatively rare on the web, and autoplaying WebAudio even more so.

(I base this on this demo, which autoplays unless I set media.autoplay.block-webaudio to true and media.autoplay.blocking_policy to 0, provided that I have Javascript enabled at all.)

The information about Firefox about:config settings in MDN's Autoplay guide for media and Web Audio APIs is somewhat outdated but might be useful, especially for media.autoplay.block-webaudio. Also, see this question and answer.

PS: A website that you've given camera or microphone permissions to is always allowed to autoplay video (or audio) regardless of your media autoplay settings. This hasn't changed since my entries in 2018 and Firefox will probably always continue to do this, since it's sensible for video conference tools.

PPS: In theory bug 1480281 might provide a way to get some information about Firefox's media autoplay decisions through either setting the MOZ_LOG environment variable or through about:networking's HTTP Logging. In practice I'm not sure if this works in release builds of Firefox. You'll probably need to read AutoplayPolicy.cpp to understand the messages.

Written on 14 June 2021.
« A strong commitment to backwards compatibility means keeping your mistakes
The challenge of what to set server BIOSes to do on power loss »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Mon Jun 14 23:00:05 2021
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.