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

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

Issue 2047333002: Pause autoplay muted video when unmuting if there's no user gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay-flag
Patch Set: Fixed accidental ws change Created 4 years, 6 months 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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 441ee5b55a8b6e020d888087c1062bc553bea0e0..50c260c45b7fe8fa549208ac4a36478718a08463 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -431,6 +431,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
, m_remoteRoutesAvailable(false)
, m_playingRemotely(false)
, m_inOverlayFullscreenVideo(false)
+ , m_isAutoplayingMuted(false)
, m_audioTracks(AudioTrackList::create(*this))
, m_videoTracks(VideoTrackList::create(*this))
, m_textTracks(nullptr)
@@ -2260,6 +2261,9 @@ void HTMLMediaElement::setMuted(bool muted)
{
DVLOG(MEDIA_LOG_LEVEL) << "setMuted(" << (void*)this << ", " << boolString(muted) << ")";
+ if (UserGestureIndicator::processingUserGesture())
+ unlockUserGesture();
+
if (m_muted == muted)
return;
@@ -2274,6 +2278,13 @@ void HTMLMediaElement::setMuted(bool muted)
Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute_Off"));
scheduleEvent(EventTypeNames::volumechange);
+
+ if (!muted && m_isAutoplayingMuted) {
foolip 2016/06/09 11:41:43 As per https://github.com/whatwg/html/issues/976 I
+ // Pause the element autoplayed muted when unmuting if there was no user gesture.
+ if (isLockedPendingUserGesture())
+ pause();
+ m_isAutoplayingMuted = false;
+ }
}
void HTMLMediaElement::updateVolume()
@@ -3671,13 +3682,17 @@ void HTMLMediaElement::unlockUserGesture()
m_lockedPendingUserGesture = false;
}
-bool HTMLMediaElement::isGestureNeededForPlayback() const
+bool HTMLMediaElement::isGestureNeededForPlayback()
{
+ m_isAutoplayingMuted = false;
+
if (!m_lockedPendingUserGesture)
return false;
- if (muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled())
+ if (muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) {
+ m_isAutoplayingMuted = true;
return false;
+ }
if (m_autoplayHelper->isGestureRequirementOverridden())
return false;
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698