Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2251073003: Pretend the video has no audio track if it is playing as part of autoplay muted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | third_party/WebKit/public/platform/WebMediaPlayerClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698