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

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

Issue 2471373005: Pretend the video has no audio track if it is playing as part of autoplay muted. (Closed)
Patch Set: 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 97ece0f6a33a98bf679519fbd12e1112e291404f..e94419abf9a06c79c5d721e5d367b329e5b83cf6 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -2347,8 +2347,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();
@@ -2358,8 +2357,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,
@@ -2375,6 +2372,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) {
@@ -3103,6 +3104,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