Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index 2e7f9801e54e65cc38afbcd0fde33499f681174c..8166f64bb4cca55ec6ce34ea7310da7de9c3f548 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -39,6 +39,7 @@ |
#include "core/dom/shadow/ShadowRoot.h" |
#include "core/events/Event.h" |
#include "core/frame/LocalFrame.h" |
+#include "core/frame/Settings.h" |
#include "core/frame/UseCounter.h" |
#include "core/frame/csp/ContentSecurityPolicy.h" |
#include "core/html/HTMLMediaSource.h" |
@@ -311,6 +312,7 @@ |
, m_fragmentStartTime(MediaPlayer::invalidTime()) |
, m_fragmentEndTime(MediaPlayer::invalidTime()) |
, m_pendingActionFlags(0) |
+ , m_userGestureRequiredForPlay(false) |
, m_playing(false) |
, m_shouldDelayLoadEvent(false) |
, m_haveFiredLoadedData(false) |
@@ -346,6 +348,9 @@ |
WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
ScriptWrappable::init(this); |
+ if (document.settings() && document.settings()->mediaPlaybackRequiresUserGesture()) |
+ m_userGestureRequiredForPlay = true; |
+ |
setHasCustomStyleCallbacks(); |
addElementToDocumentMap(this, &document); |
} |
@@ -692,6 +697,9 @@ |
{ |
WTF_LOG(Media, "HTMLMediaElement::load()"); |
+ if (UserGestureIndicator::processingUserGesture()) |
+ m_userGestureRequiredForPlay = false; |
+ |
prepareForLoad(); |
loadInternal(); |
prepareToPlay(); |
@@ -939,7 +947,9 @@ |
bool attemptLoad = true; |
if (url.protocolIs(mediaSourceBlobProtocol)) { |
- if (!isMediaStreamURL(url.string())) { |
+ if (isMediaStreamURL(url.string())) { |
+ m_userGestureRequiredForPlay = false; |
+ } else { |
m_mediaSource = HTMLMediaSource::lookup(url.string()); |
if (m_mediaSource) { |
@@ -1817,7 +1827,7 @@ |
scheduleEvent(EventTypeNames::playing); |
} |
- if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(SandboxAutomaticFeatures)) { |
+ if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(SandboxAutomaticFeatures) && !m_userGestureRequiredForPlay) { |
m_paused = false; |
invalidateCachedTime(); |
scheduleEvent(EventTypeNames::play); |
@@ -2187,6 +2197,11 @@ |
void HTMLMediaElement::play() |
{ |
WTF_LOG(Media, "HTMLMediaElement::play()"); |
+ |
+ if (m_userGestureRequiredForPlay && !UserGestureIndicator::processingUserGesture()) |
+ return; |
+ if (UserGestureIndicator::processingUserGesture()) |
+ m_userGestureRequiredForPlay = false; |
playInternal(); |
} |