Bug 834146 - [Audio] When initilizing AudioChannelAgent, we should set visibility correctly in that time. r=kinetik, a=tef+
authorMarco Chen <mchen@mozilla.com>
Fri, 25 Jan 2013 11:00:43 +0800
changeset 118333 56254819e70e
parent 118332 ed53e2df9157
child 118334 deb5185f2af9
push id357
push userjst@mozilla.com
push dateFri, 25 Jan 2013 08:49:19 +0000
reviewerskinetik, tef
bugs834146
milestone18.0
Bug 834146 - [Audio] When initilizing AudioChannelAgent, we should set visibility correctly in that time. r=kinetik, a=tef+
content/html/content/src/nsHTMLMediaElement.cpp
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -3823,16 +3823,23 @@ void nsHTMLMediaElement::UpdateAudioChan
 
     if (!mAudioChannelAgent) {
       nsresult rv;
       mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
       if (!mAudioChannelAgent) {
         return;
       }
       mAudioChannelAgent->Init(mAudioChannelType, this);
+
+      nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(OwnerDoc());
+      if (domDoc) {
+        bool hidden = false;
+        domDoc->GetHidden(&hidden);
+        mAudioChannelAgent->SetVisibilityState(!hidden);
+      }
     }
 
     if (mPlayingThroughTheAudioChannel) {
       bool canPlay;
       mAudioChannelAgent->StartPlaying(&canPlay);
     } else {
       mAudioChannelAgent->StopPlaying();
       mAudioChannelAgent = nullptr;