Bug 1299096 - Remove the event-based play() method out from nsIDOMHTMLMediaElement.idl; r?bz draft
authorKaku Kuo <kaku@mozilla.com>
Tue, 13 Dec 2016 16:04:45 +0800
changeset 455573 14ef5e6068f6d233fb7666e0585edfcb0ff69d06
parent 455536 57ac9f63fc6953f4efeb0cc84a60192d3721251f
child 541036 076d9bc83caa87ab4b70f5b27e0c01f0453c7735
push id40287
push userbmo:kaku@mozilla.com
push dateWed, 04 Jan 2017 07:12:20 +0000
reviewersbz
bugs1299096
milestone53.0a1
Bug 1299096 - Remove the event-based play() method out from nsIDOMHTMLMediaElement.idl; r?bz MozReview-Commit-ID: 3pHsSsADPLu
dom/html/HTMLMediaElement.cpp
dom/interfaces/html/nsIDOMHTMLMediaElement.idl
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -880,19 +880,22 @@ private:
     if (!IsSuspended()) {
       MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
              ("HTMLMediaElement::AudioChannelAgentCallback, ResumeFromAudioChannel, "
               "this = %p, Error : resume without suspended!\n", this));
       return;
     }
 
     SetSuspended(nsISuspendedTypes::NONE_SUSPENDED);
-    nsresult rv = mOwner->Play();
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return;
+    IgnoredErrorResult rv;
+    RefPtr<Promise> toBeIgnored = mOwner->Play(rv);
+    MOZ_ASSERT_IF(toBeIgnored && toBeIgnored->State() == Promise::PromiseState::Rejected,
+                  rv.Failed());
+    if (rv.Failed()) {
+      NS_WARNING("Not able to resume from AudioChannel.");
     }
   }
 
   void
   Suspend(SuspendTypes aSuspend)
   {
     if (IsSuspended()) {
       return;
@@ -3862,33 +3865,16 @@ HTMLMediaElement::PlayInternal(ErrorResu
 void
 HTMLMediaElement::MaybeDoLoad()
 {
   if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
     DoLoad();
   }
 }
 
-NS_IMETHODIMP HTMLMediaElement::Play()
-{
-  if (mAudioChannelWrapper && mAudioChannelWrapper->IsPlaybackBlocked()) {
-    MaybeDoLoad();
-    return NS_OK;
-  }
-
-  ErrorResult rv;
-  RefPtr<Promise> toBeIgnored = PlayInternal(rv);
-  if (rv.Failed()) {
-    return rv.StealNSResult();
-  }
-
-  UpdateCustomPolicyAfterPlayed();
-  return NS_OK;
-}
-
 HTMLMediaElement::WakeLockBoolWrapper&
 HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val)
 {
   if (mValue == val) {
     return *this;
   }
 
   mValue = val;
--- a/dom/interfaces/html/nsIDOMHTMLMediaElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLMediaElement.idl
@@ -60,17 +60,16 @@ interface nsIDOMHTMLMediaElement : nsISu
            attribute double playbackRate;
            attribute boolean mozPreservesPitch;
   readonly attribute nsIDOMTimeRanges played;
   readonly attribute nsIDOMTimeRanges seekable;
   readonly attribute boolean ended;
   readonly attribute boolean mozAutoplayEnabled;
            attribute boolean autoplay;
            attribute boolean loop;
-  void play();
   void pause();
 
   // controls
            attribute boolean controls;
            attribute double volume;
            attribute boolean muted;
            attribute boolean defaultMuted;