Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add option to disable AudioContext autoplay #33590

Open
andy-fillebrown opened this issue Nov 13, 2024 · 2 comments
Open

[Feature]: Add option to disable AudioContext autoplay #33590

andy-fillebrown opened this issue Nov 13, 2024 · 2 comments
Labels

Comments

@andy-fillebrown
Copy link

🚀 Feature Request

When creating a new AudioContext, its initial state is "running", which is good for testing audio, but does not reflect the initial state encountered by users of a website, which is "suspended" and requires a user interaction for the AudioContext.resume() promise to resolve.

If possible, please add an option that makes AudioContext's initial state "suspended", and require a user interaction for the AudioContext.resume() promise to resolve.

Example

No response

Motivation

This would make it possible to test the user interaction requirements for autoplay implemented by browsers. See https://developer.chrome.com/blog/autoplay for more info on Chrome's requirements. Webkit's requirements are similar.

@pavelfeldman
Copy link
Member

Could you provide a full repro case and example of proposed API?

@andy-fillebrown
Copy link
Author

andy-fillebrown commented Nov 13, 2024

It may not be possible without changing the browser build settings. See bootstrap.diff:23122 for the webkit build for example.

I assume there's something similar for the chromium build. It might be better to leave the autoplay build settings alone so autoplay is disabled by default, and then add CLI flags for each browser to enable it. So for chromium the flag to set would be --autoplay-policy=no-user-gesture-required. I'm not sure if there are Firefox and Webkit equivalents.

If it were done that way then ignoreDefaultArgs could be used to disable autoplay: https://playwright.dev/docs/api/class-browsertype#browser-type-launch-option-ignore-default-args.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants