Closed Bug 1516106 Opened 7 years ago Closed 7 years ago

Extend media.autoplay.enabled to prevent autoplay via Javascript

Categories

(Core :: Audio/Video: Playback, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: allo, Unassigned)

Details

More and more sites do not use normal autoplay videos, but start them using Javascript. The preference media.autoplay.enabled should be extended to disable the Javascript API for starting a video until the user interacts with the video element by click or touch (not mouseover or similar).
Component: General → Audio/Video: Playback
Product: Firefox → Core

alex, can you provide us with an example site that exhibits this behaviour?

Flags: needinfo?(allo)

We already have that in Nightly. Our autoplay policy would prevent audible video starting by javascript, until the document is activated by user gesture.

(In reply to Alastor Wu [:alwu] from comment #2)

We already have that in Nightly. Our autoplay policy would prevent audible video starting by javascript, until the document is activated by user gesture.
Can we simply get a setting to disable the whole autoplay in this case (and I hope that user gesture means click or keyboard input when the video has the focus, not "mouseover")

(In reply to Bryce Seager van Dyk (:bryce) from comment #1)

alex, can you provide us with an example site that exhibits this behaviour?
Do you still need an example, when there is code in the nightly? I could try to build a minimal example or answer when I notice the next site which does this, but in the end it should result in "disable the video.play JS API until the user clicks on the <video> element", which possibly is the same as the code in the nightly does.

Flags: needinfo?(bvandyk)

(In reply to Alastor Wu [:alwu] from comment #2)

We already have that in Nightly. Our autoplay policy would prevent audible video starting by javascript, until the document is activated by user gesture.

Can we simply get a setting to disable the whole autoplay in this case (and I hope that user gesture means click or keyboard input when the video has the focus, not "mouseover")

(In reply to Bryce Seager van Dyk (:bryce) from comment #1)

alex, can you provide us with an example site that exhibits this behaviour?

Do you still need an example, when there is code in the nightly? I could try to build a minimal example or answer when I notice the next site which does this, but in the end it should result in "disable the video.play JS API until the user clicks on the element", which possibly is the same as the code in the nightly does.

An example of a site doing this would be useful to verify if the case you're concerned with is addressed in nightly.

Flags: needinfo?(bvandyk)

(In reply to Bryce Seager van Dyk (:bryce) from comment #5)

An example of a site doing this would be useful to verify if the case you're concerned with is addressed in nightly.

When you use tweetdeck.twitter.com and expand a tweet with a native video (hosted by twitter) in one of its columns, it starts playing even with sound.
Set in preferences: media.autoplay.enabled;false

The main twitter site seems to require a click, so you need to use tweetdeck to test it.

Flags: needinfo?(allo)

(In reply to alex from comment #6)

(In reply to Bryce Seager van Dyk (:bryce) from comment #5)

An example of a site doing this would be useful to verify if the case you're concerned with is addressed in nightly.

When you use tweetdeck.twitter.com and expand a tweet with a native video
(hosted by twitter) in one of its columns, it starts playing even with sound.
Set in preferences: media.autoplay.enabled;false

expand a tweet, do you mean clicking on the tweet and then it would show the full content? If so, at the moment you're clicking the website, you have activated the site by user gesture, that is why they can start autoplay. This is a rule of the auser-gesture-activationa model, we will allow autoplay after docuement is activated by user gesture (eg. click, keyboard press, touch...).


Which version firefox are you using?

media.autoplay.enabled is an old preference, now we use media.autoplay.default. you can set it to 1 to prevent media from autoplay. Also, it you're using Nightly, you can also change it via the setting page (go to about:preferences#privacy).

Flags: needinfo?(allo)

(In reply to Alastor Wu [:alwu] from comment #7)

expand a tweet, do you mean clicking on the tweet and then it would show the full content? If so, at the moment you're clicking the website, you have activated the site by user gesture, that is why they can start autoplay. This is a rule of the auser-gesture-activationa model, we will allow autoplay after docuement is activated by user gesture (eg. click, keyboard press, touch...).
I click into an empty space (next to a placeholder), which lets the column content slide to the left and slide in new content from the right, probably loaded via AJAX. I did not click a video element or placeholder.

If any interaction with the website is sufficient, I would like to have another "strict-no-autoplay" option, which prevents videos from playing until I click a play button. Doing something somewhere in a website should not trigger a video in another part of the website.

Which version firefox are you using?

media.autoplay.enabled is an old preference, now we use media.autoplay.default. you can set it to 1 to prevent media from autoplay. Also, it you're using Nightly, you can also change it via the setting page (go to about:preferences#privacy).

64.0

I'll try the new settings, I just saw there are a bunch of new ones:
https://www.ghacks.net/2018/09/21/firefox-improved-autoplay-blocking/

Flags: needinfo?(allo)

(In reply to alex from comment #8)

If any interaction with the website is sufficient, I would like to have another "strict-no-autoplay" option, which prevents videos from playing until I click a play button. Doing something somewhere in a website should not trigger a video in another part of the website.

You can set the pref "media.autoplay.enabled.user-gestures-needed=false" which would only allow click-to-play, however, it would break some sites because any async video.play() call from user click handler won't be regard as part of user input. It will be fixed by bug1185052.

In addition, we're thinking about to replace current autoplay policy from user-gesture-activation with click-to-play, but we're still evaluating it because it will probably break those sites who don't have explict control interface for their autoplay media and who are using web audio for autoplay. That is tracking by bug1509933.

I'll try the new settings, I just saw there are a bunch of new ones:
https://www.ghacks.net/2018/09/21/firefox-improved-autoplay-blocking/

This is also out-of-date, we've removed the prompt in Nightly because we didn't get the good feedback about the prompt from the shield-study we've launched in Fx release 63.

As we allow autoplay after page has been activated by user gesture, I would make this bug as INVALID because it's the rule of user-gesture-activation model.

If user want to user click-to-play model, please turn off the pref media.autoplay.enabled.user-gestures-needed, but some websites which are not compatible with this model might be broke.

Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID

I can confirm, that in Firefox 65 the new settings provide all the autoplay protection that I need. A migration from the old setting would have been nice, though.

You need to log in before you can comment on or make changes to this bug.