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: Shuffled the logic for MediaSource in load resource a bit 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..a7a7914e5b1edadc0b15d364035c0f0d809dcafe 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -1031,21 +1031,17 @@ void HTMLMediaElement::loadResource(const WebMediaPlayerSource& source, const Co
bool attemptLoad = true;
+ // MediaSource is a blob URL that is not a media stream.
foolip 2016/06/28 15:28:51 This comment doesn't seem quite accurate, if it's
whywhat 2016/06/28 16:13:50 Done. I inlined |isObject| since it made the expre
whywhat 2016/06/28 18:06:34 So loadType() doesn't catch corrupt or revoked med
foolip 2016/06/29 09:30:27 Actually I think that it's the test that should ch
bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourceBlobProtocol);
foolip 2016/06/28 15:28:51 While you're here, may I suggest replacing mediaSo
whywhat 2016/06/28 16:13:50 Done.
- 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;
- }
+ if (isStreamOrBlobUrl && !source.isMediaStream() && (!source.isURL() || !isMediaStreamURL(url.getString()))) {
sof 2016/06/27 19:28:48 Can (at least) be reduced to if (url.protocolIs(m
whywhat 2016/06/28 16:13:50 I believe now it's even simpler.
+ m_mediaSource = HTMLMediaSource::lookup(url.getString());
+
+ if (m_mediaSource) {
+ if (!m_mediaSource->attachToElement(this)) {
sof 2016/06/27 19:28:48 nit: the two ifs could be fused.
whywhat 2016/06/28 16:13:50 Ditto.
whywhat 2016/06/28 18:06:34 Actually fused these diffs :)
+ // Forget our reference to the MediaSource, so we leave it alone
+ // while processing remainder of load failure.
+ m_mediaSource = nullptr;
+ attemptLoad = false;
}
}
}
@@ -1223,7 +1219,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())))
foolip 2016/06/28 15:28:51 Did this assert somewhere before?
whywhat 2016/06/28 16:13:50 isMediaStreamURL is using a hash map that eventual
return WebMediaPlayer::LoadTypeMediaStream;
return WebMediaPlayer::LoadTypeURL;
@@ -3725,6 +3721,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