Bug 1391666 - Part 2: Reset mWaitingForKey when we have data and autoplay attribute is set. r=cpearce, a=lizzard
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 18 Aug 2017 19:20:48 +0200
changeset 423699 53d7d0601775bdd794e1099ffaebe6afad3708f7
parent 423698 4e6b8a64e613a2400644deb2fee5fcacef3f1f03
child 423700 065ea81827aeffc6d1ea57ad7c31f5684a66bd87
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lizzard
bugs1391666
milestone56.0
Bug 1391666 - Part 2: Reset mWaitingForKey when we have data and autoplay attribute is set. r=cpearce, a=lizzard By default, a media element that has never played is in paused mode. As such, we need to reset mWaitingForKey to NOT_WAITING_FOR_KEY otherwise, readyState will never become HAVE_ENOUGH_DATA. MozReview-Commit-ID: EIi3Crt4zHl
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5891,21 +5891,25 @@ void HTMLMediaElement::ChangeReadyState(
     DispatchAsyncEvent(NS_LITERAL_STRING("loadeddata"));
     mLoadedDataFired = true;
   }
 
   if (oldState < nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA &&
       mReadyState >= nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA) {
     DispatchAsyncEvent(NS_LITERAL_STRING("canplay"));
     if (!mPaused) {
-      mWaitingForKey = NOT_WAITING_FOR_KEY;
       NotifyAboutPlaying();
     }
   }
 
+  if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA &&
+      (!mPaused || mAutoplaying)) {
+    mWaitingForKey = NOT_WAITING_FOR_KEY;
+  }
+
   CheckAutoplayDataReady();
 
   if (oldState < nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA &&
       mReadyState >= nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA) {
     DispatchAsyncEvent(NS_LITERAL_STRING("canplaythrough"));
   }
 }