Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
index 56ad755a6e9c9743151d0a62dc99d5335758bdd9..22421d0c2ad1c21e29707167c341e6d3e66c62a2 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
@@ -2353,8 +2353,7 @@ void HTMLMediaElement::setMuted(bool muted) { |
if (m_muted == muted) |
return; |
- bool wasAutoplayingMuted = |
- !paused() && m_muted && isLockedPendingUserGesture(); |
+ bool wasAutoplayingMuted = isAutoplayingMuted(); |
bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && |
m_muted && isLockedPendingUserGesture(); |
@@ -2364,8 +2363,6 @@ void HTMLMediaElement::setMuted(bool muted) { |
m_muted = muted; |
m_autoplayHelper->mutedChanged(); |
- updateVolume(); |
- |
scheduleEvent(EventTypeNames::volumechange); |
// If an element autoplayed while muted, it needs to be unlocked to unmute, |
@@ -2381,6 +2378,10 @@ void HTMLMediaElement::setMuted(bool muted) { |
} |
} |
+ // This is called after the volumechange event to make sure isAutoplayingMuted |
+ // returns the right value when webMediaPlayer receives the volume update. |
+ updateVolume(); |
+ |
// If an element was a candidate for autoplay muted but not visible, it will |
// have a visibility observer ready to start its playback. |
if (wasPendingAutoplayMuted) { |
@@ -3109,6 +3110,15 @@ void HTMLMediaElement::cancelledRemotePlaybackRequest() { |
remotePlaybackClient()->promptCancelled(); |
} |
+bool HTMLMediaElement::isAutoplayingMuted() { |
+ if (!isHTMLVideoElement() || |
+ !RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { |
+ return false; |
+ } |
+ |
+ return !paused() && muted() && isLockedPendingUserGesture(); |
+} |
+ |
void HTMLMediaElement::requestReload(const WebURL& newUrl) { |
DCHECK(webMediaPlayer()); |
DCHECK(!m_srcObject); |