Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daleharvey/b8aa78a589c356fe7cef1649a5018319 to your computer and use it in GitHub Desktop.
Save daleharvey/b8aa78a589c356fe7cef1649a5018319 to your computer and use it in GitHub Desktop.
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -119,7 +119,8 @@ static bool IsWindowAllowedToPlay(nsPIDOMWindowInner* aWindow) {
static uint32_t DefaultAutoplayBehaviour() {
int prefValue =
Preferences::GetInt("media.autoplay.default", nsIAutoplay::ALLOWED);
- if (prefValue < nsIAutoplay::ALLOWED || prefValue > nsIAutoplay::BLOCKED) {
+ if (prefValue < nsIAutoplay::ALLOWED || prefValue > nsIAutoplay::BLOCKED_ALL) {
// Invalid pref values are just converted to BLOCKED.
return nsIAutoplay::BLOCKED;
}
@@ -127,8 +128,11 @@ static uint32_t DefaultAutoplayBehaviour() {
}
static bool IsMediaElementAllowedToPlay(const HTMLMediaElement& aElement) {
- const bool isAllowedMuted =
- Preferences::GetBool("media.autoplay.allow-muted", true);
+ const bool isAllowedMuted = DefaultAutoplayBehaviour() != nsIAutoplay::BLOCKED_ALL;
if ((aElement.Volume() == 0.0 || aElement.Muted()) && isAllowedMuted) {
AUTOPLAY_LOG("Allow muted media %p to autoplay.", &aElement);
return true;
// Above lets setting media.autoplay.default
bool nsContentUtils::IsSitePermDeny(nsIPrincipal* aPrincipal,
const nsACString& aType) {
return TestSitePerm(aPrincipal, aType, nsIPermissionManager::DENY_ACTION,
false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment