Bug 1477415 - part1 : allow video document autoplay. draft
authoralwu <alwu@mozilla.com>
Mon, 23 Jul 2018 11:17:00 -0700
changeset 822667 1c7b512ac526c3af59c94c340b50e593845c04c3
parent 822648 4c4abe35d80851590954b52eabf828c763104696
child 822668 3c76d7c515e11348ed4ce703f670ef168c1625e5
push id117433
push userbmo:alwu@mozilla.com
push dateWed, 25 Jul 2018 16:33:31 +0000
bugs1477415
milestone63.0a1
Bug 1477415 - part1 : allow video document autoplay. Allow autoplay for video document when user is directly viewing a video/audio by visiting its url. MozReview-Commit-ID: GnSxx32h6hm
dom/media/AutoplayPolicy.cpp
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -99,18 +99,19 @@ DefaultAutoplayBehaviour()
   }
   return prefValue;
 }
 
 static bool
 IsMediaElementAllowedToPlay(const HTMLMediaElement& aElement)
 {
   return ((aElement.Volume() == 0.0 || aElement.Muted()) &&
-          Preferences::GetBool("media.autoplay.allow-muted", true)) ||
-         IsWindowAllowedToPlay(aElement.OwnerDoc()->GetInnerWindow());
+           Preferences::GetBool("media.autoplay.allow-muted", true)) ||
+          IsWindowAllowedToPlay(aElement.OwnerDoc()->GetInnerWindow()) ||
+          (aElement.OwnerDoc()->MediaDocumentKind() == nsIDocument::MediaDocumentKind::Video);
 }
 
 /* static */ bool
 AutoplayPolicy::WouldBeAllowedToPlayIfAutoplayDisabled(const HTMLMediaElement& aElement)
 {
   return IsMediaElementAllowedToPlay(aElement);
 }