Bug 1483703 - part1 : allow media without audio track to autoplay. r=cpearce
authoralwu <alwu@mozilla.com>
Tue, 21 Aug 2018 20:58:26 +0000
changeset 490681 cd6a42517bb9e60c45b6441a986b53d8da7fb147
parent 490680 d77ca862636da2f413aa0b3a6e98c11c45ecae15
child 490682 d57a6d415507fb7e43cad18c2755aa124b84bbbe
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1483703
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1483703 - part1 : allow media without audio track to autoplay. r=cpearce We would allow media without audio track to autoplay after it had loaded the metadata. If media hasn't loaded metadata yet, we would treat it as audible media and then block it. Differential Revision: https://phabricator.services.mozilla.com/D3670
dom/media/AutoplayPolicy.cpp
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -142,16 +142,22 @@ IsMediaElementAllowedToPlay(const HTMLMe
 
   nsIDocument* topDocument = ApproverDocOf(*aElement.OwnerDoc());
   if (topDocument &&
       topDocument->MediaDocumentKind() == nsIDocument::MediaDocumentKind::Video) {
     AUTOPLAY_LOG("Allow video document %p to autoplay\n", &aElement);
     return true;
   }
 
+  if (!aElement.HasAudio() &&
+      aElement.ReadyState() >= HTMLMediaElement_Binding::HAVE_METADATA) {
+    AUTOPLAY_LOG("Allow media without audio track %p to autoplay\n", &aElement);
+    return true;
+  }
+
   return false;
 }
 
 /* static */ bool
 AutoplayPolicy::WouldBeAllowedToPlayIfAutoplayDisabled(const HTMLMediaElement& aElement)
 {
   return IsMediaElementAllowedToPlay(aElement);
 }