Bug 1304134. Part 1 - per spec. (https://dev.w3.org/html5/spec-preview/media-elements.html#ready-states) 'playing' should be fired before activating autoplay. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 23 Sep 2016 14:03:50 +0800
changeset 417511 4e435cb8f41a1b65cdf42801390c5b44d3777c57
parent 416853 261ebf4a551f99cfb17655d5af3414ddfdf3fb44
child 417512 852a1cd8c86b573b01b4350833a99a50db7fa6ca
push id30409
push userjwwang@mozilla.com
push dateMon, 26 Sep 2016 02:30:09 +0000
bugs1304134
milestone52.0a1
Bug 1304134. Part 1 - per spec. (https://dev.w3.org/html5/spec-preview/media-elements.html#ready-states) 'playing' should be fired before activating autoplay. Also replace the check for IsPotentiallyPlaying() with !mPaused because mReadyState >= HAVE_FUTURE_DATA guarantees playback is not ended. MozReview-Commit-ID: HetaVDgYEW0
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4876,27 +4876,24 @@ void HTMLMediaElement::ChangeReadyState(
       !mLoadedDataFired) {
     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 = false;
+      DispatchAsyncEvent(NS_LITERAL_STRING("playing"));
+    }
   }
 
   CheckAutoplayDataReady();
 
-  if (oldState < nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA &&
-      mReadyState >= nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA &&
-      IsPotentiallyPlaying()) {
-    mWaitingForKey = false;
-    DispatchAsyncEvent(NS_LITERAL_STRING("playing"));
-  }
-
   if (oldState < nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA &&
       mReadyState >= nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA) {
     DispatchAsyncEvent(NS_LITERAL_STRING("canplaythrough"));
   }
 }
 
 static const char* const gNetworkStateToString[] = {
   "EMPTY",