Bug 1351087 - part1 : don't register agent for audio without audio track. r=baku a=gchang
authorAlastor Wu <alwu@mozilla.com>
Tue, 09 May 2017 14:10:43 +0800
changeset 585350 659ecca63ea66d76d26eb366030b4c43c2c6e786
parent 581869 0241994e3aad3594cae0d42c7d80a2dff7b245e8
child 585351 2adc92ca880875a4728d3499154a76fadcadfa0a
push id61106
push userbmo:dkeeler@mozilla.com
push dateFri, 26 May 2017 21:26:31 +0000
reviewersbaku, gchang
bugs1351087
milestone54.0
Bug 1351087 - part1 : don't register agent for audio without audio track. r=baku a=gchang Since we don't want to show media control for media without audio track (eg. GIFV), it's no need to register audio agent for them. MozReview-Commit-ID: 22YrMkpNrcP
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1043,16 +1043,21 @@ private:
       return true;
     }
 
     // Are we paused
     if (mOwner->mPaused) {
       return false;
     }
 
+    // No audio track
+    if (!mOwner->HasAudio()) {
+      return false;
+    }
+
     // A loop always is playing
     if (mOwner->HasAttr(kNameSpaceID_None, nsGkAtoms::loop)) {
       return true;
     }
 
     // If we are actually playing...
     if (mOwner->IsCurrentlyPlaying()) {
       return true;
@@ -7095,16 +7100,17 @@ HTMLMediaElement::ShouldElementBePaused(
 }
 
 void
 HTMLMediaElement::SetMediaInfo(const MediaInfo& aInfo)
 {
   const bool oldHasAudio = mMediaInfo.HasAudio();
   mMediaInfo = aInfo;
   if (aInfo.HasAudio() != oldHasAudio) {
+    UpdateAudioChannelPlayingState();
     NotifyAudioPlaybackChanged(
       AudioChannelService::AudibleChangedReasons::eDataAudibleChanged);
   }
   if (mAudioChannelWrapper) {
     mAudioChannelWrapper->AudioCaptureStreamChangeIfNeeded();
   }
 }