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

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

Issue 2075563003: [Android, Media] Don't unlock MediaStream elements; instead allow MS to autoplay without a gesture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed media source test 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/LayoutTests/media/autoplay-from-mediastream-to-src.html ('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 bff62e7bfdb250473405fbd5bc2215a8d99b8bf2..8a376043b7484bb701cd83c32919f2b8174d3aec 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -119,9 +119,6 @@ using DocumentElementSetMap = HeapHashMap<WeakMember<Document>, Member<WeakMedia
namespace {
-// URL protocol used to signal that the media source API is being used.
-const char mediaSourceBlobProtocol[] = "blob";
-
enum MediaControlsShow {
MediaControlsShowAttribute = 0,
MediaControlsShowFullscreen,
@@ -1031,23 +1028,12 @@ void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co
bool attemptLoad = true;
- bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourceBlobProtocol);
- if (isStreamOrBlobUrl) {
- bool isMediaStream = source.isMediaStream() || (source.isURL() && isMediaStreamURL(url.getString()));
- if (isMediaStream) {
- m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByStream);
- } else {
- m_mediaSource = HTMLMediaSource::lookup(url.getString());
-
- if (m_mediaSource) {
- if (!m_mediaSource->attachToElement(this)) {
- // Forget our reference to the MediaSource, so we leave it alone
- // while processing remainder of load failure.
- m_mediaSource = nullptr;
- attemptLoad = false;
- }
- }
- }
+ m_mediaSource = HTMLMediaSource::lookup(url.getString());
+ if (m_mediaSource && !m_mediaSource->attachToElement(this)) {
+ // Forget our reference to the MediaSource, so we leave it alone
+ // while processing remainder of load failure.
+ m_mediaSource = nullptr;
+ attemptLoad = false;
}
bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType);
@@ -1057,7 +1043,7 @@ void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co
// Conditionally defer the load if effective preload is 'none'.
// Skip this optional deferral for MediaStream sources or any blob URL,
// including MediaSource blob URLs.
- if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::PreloadNone) {
+ if (!source.isMediaStream() && !url.protocolIs("blob") && effectivePreloadType() == WebMediaPlayer::PreloadNone) {
MEDIA_LOG << "loadResource(" << (void*)this << ") : Delaying load because preload == 'none'";
deferLoad();
} else {
@@ -1223,7 +1209,7 @@ WebMediaPlayer::LoadType HTMLMediaElement::loadType() const
if (m_mediaSource)
return WebMediaPlayer::LoadTypeMediaSource;
- if (m_srcObject || isMediaStreamURL(m_currentSrc.getString()))
+ if (m_srcObject || (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc.getString())))
return WebMediaPlayer::LoadTypeMediaStream;
return WebMediaPlayer::LoadTypeURL;
@@ -3725,6 +3711,9 @@ bool HTMLMediaElement::isGestureNeededForPlayback() const
if (!m_lockedPendingUserGesture)
return false;
+ if (loadType() == WebMediaPlayer::LoadTypeMediaStream)
+ return false;
+
// We want to allow muted video to autoplay if:
// - the flag is enabled;
// - Data Saver is not enabled;
« no previous file with comments | « third_party/WebKit/LayoutTests/media/autoplay-from-mediastream-to-src.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698