Implement `document.autoplayPolicy` API

RESOLVED FIXED in Firefox 66

Status

()

enhancement
P2
normal
RESOLVED FIXED
5 months ago
a month ago

People

(Reporter: alwu, Assigned: alwu)

Tracking

(Depends on 1 bug, {dev-doc-needed})

unspecified
mozilla66
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox66 fixed)

Details

Attachments

(2 attachments)

(Assignee)

Description

5 months ago
`document.autoplayPolicy` returns a enum string that can change overtime based on user session activity [1]:

- “allowed” if autoplay is currently allowed.
- “allowed-muted” if muted video autoplay is currently allowed.
- “disallowed” is autoplay is not current allowed.
- “prompt” if autoplay will trigger a prompt

[1] https://github.com/WICG/autoplay/issues/1
(Assignee)

Comment 1

5 months ago
`document.autoplayPolicy` returns a enum string that can change overtime based on user session activity:

- “allowed” if autoplay is currently allowed.
- “allowed-muted” if muted video autoplay is currently allowed.
- “disallowed” is autoplay is not current allowed.
- “prompt” if autoplay will trigger a prompt
(Assignee)

Comment 2

5 months ago
Before fixing bug1493766, we can't write tests because now AutoplayPolicy::IsAllowedToPlay() would return incorrectly result under some situaions. 

I will write the wpt-test after fixing bug1493766.
Depends on: 1493766
(Assignee)

Comment 3

5 months ago
The proposal [1] defines that `document.autoplayPolicy` returns a single enum string, but it doesn't meet our current implementation. “allowed-muted” and “prompt” can exist at the same time. 

Therefore, we can't implement this API now, we need to wait for the decision about whether shipping the doorhanger. If not, we can implement this single enum version, but if we want to ship with doorhanger, we need to modify the proposal in order to make API return multiple enums strings.
Priority: -- → P2
Attachment #9024153 - Attachment description: Bug 1506290 - implement 'document.autoplayPolicy'. → Bug 1506290 - part1 : implement 'document.autoplayPolicy'.
(Assignee)

Comment 4

4 months ago

Comment 6

3 months ago
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/63c3828351f0
part1 : implement 'document.autoplayPolicy'. r=baku,cpearce
https://hg.mozilla.org/integration/autoland/rev/3420cf8f79a9
part2 : add test. r=cpearce

Comment 7

3 months ago
bugherder
Status: NEW → RESOLVED
Last Resolved: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66

:cmills-- when we get to the docs for this one, I'll take it.

(In reply to Eric Shepherd [:sheppy] from comment #8)

:cmills-- when we get to the docs for this one, I'll take it.

WFM; I've added you to the relevant MDN roadmap card: https://trello.com/c/4emMB6Y8/146-autoplay-api-fx-66

Again, I don't think this is available in 66; see https://bugzilla.mozilla.org/show_bug.cgi?id=1487844#c9. I could be wrong.

(Assignee)

Comment 11

2 months ago

This API is controled by the pref "dom.media.autoplay.autoplay-policy-api", which is default off. If user turns on this pref in 66, then they can use the API no matter whether we enable blocking autoplay or not.

I've added this to the "experimental features in Firefox" page. It's currently mentioned on the Fx for 66 page, but can be removed if we decide to.

(Assignee)

Updated

a month ago
No longer blocks: 1506289
Depends on: 1506289
(Assignee)

Comment 13

a month ago

(In reply to Eric Shepherd [:sheppy] from comment #12)

I've added this to the "experimental features in Firefox" page. It's currently mentioned on the Fx for 66 page, but can be removed if we decide to.

It sounds good to me to mention that this API is just an experimental feature which hasn't be a part of the offical spec, thank you.

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