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

Side by Side 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: Whitespace changes Created 4 years, 5 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1025
1026 if (fastHasAttribute(mutedAttr)) 1026 if (fastHasAttribute(mutedAttr))
1027 m_muted = true; 1027 m_muted = true;
1028 updateVolume(); 1028 updateVolume();
1029 1029
1030 DCHECK(!m_mediaSource); 1030 DCHECK(!m_mediaSource);
1031 1031
1032 bool attemptLoad = true; 1032 bool attemptLoad = true;
1033 1033
1034 bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourc eBlobProtocol); 1034 bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourc eBlobProtocol);
1035 if (isStreamOrBlobUrl) { 1035 if (isStreamOrBlobUrl) {
sof 2016/06/27 15:10:47 The logic looks a bit strange now - more readable
whywhat 2016/06/27 15:35:58 Ok, I guess the overall condition triggering the c
sof 2016/06/27 18:54:06 That makes it a lot clearer, i.e., check if a medi
whywhat 2016/06/27 19:00:50 Not sure if it became much more clearer but I took
1036 bool isMediaStream = source.isMediaStream() || (source.isURL() && isMedi aStreamURL(url.getString())); 1036 bool isMediaStream = source.isMediaStream() || (source.isURL() && isMedi aStreamURL(url.getString()));
1037 if (isMediaStream) { 1037 if (!isMediaStream) {
1038 m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByStre am);
1039 } else {
1040 m_mediaSource = HTMLMediaSource::lookup(url.getString()); 1038 m_mediaSource = HTMLMediaSource::lookup(url.getString());
1041 1039
1042 if (m_mediaSource) { 1040 if (m_mediaSource) {
1043 if (!m_mediaSource->attachToElement(this)) { 1041 if (!m_mediaSource->attachToElement(this)) {
1044 // Forget our reference to the MediaSource, so we leave it a lone 1042 // Forget our reference to the MediaSource, so we leave it a lone
1045 // while processing remainder of load failure. 1043 // while processing remainder of load failure.
1046 m_mediaSource = nullptr; 1044 m_mediaSource = nullptr;
1047 attemptLoad = false; 1045 attemptLoad = false;
1048 } 1046 }
1049 } 1047 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 } 1214 }
1217 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask); 1215 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask);
1218 m_deferredLoadState = WaitingForTrigger; 1216 m_deferredLoadState = WaitingForTrigger;
1219 } 1217 }
1220 1218
1221 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const 1219 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const
1222 { 1220 {
1223 if (m_mediaSource) 1221 if (m_mediaSource)
1224 return WebMediaPlayer::LoadTypeMediaSource; 1222 return WebMediaPlayer::LoadTypeMediaSource;
1225 1223
1226 if (m_srcObject || isMediaStreamURL(m_currentSrc.getString())) 1224 if (m_srcObject || (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc. getString())))
1227 return WebMediaPlayer::LoadTypeMediaStream; 1225 return WebMediaPlayer::LoadTypeMediaStream;
1228 1226
1229 return WebMediaPlayer::LoadTypeURL; 1227 return WebMediaPlayer::LoadTypeURL;
1230 } 1228 }
1231 1229
1232 bool HTMLMediaElement::textTracksAreReady() const 1230 bool HTMLMediaElement::textTracksAreReady() const
1233 { 1231 {
1234 // 4.8.10.12.1 Text track model 1232 // 4.8.10.12.1 Text track model
1235 // ... 1233 // ...
1236 // The text tracks of a media element are ready if all the text tracks whose mode was not 1234 // The text tracks of a media element are ready if all the text tracks whose mode was not
(...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 void HTMLMediaElement::unlockUserGesture() 3716 void HTMLMediaElement::unlockUserGesture()
3719 { 3717 {
3720 m_lockedPendingUserGesture = false; 3718 m_lockedPendingUserGesture = false;
3721 } 3719 }
3722 3720
3723 bool HTMLMediaElement::isGestureNeededForPlayback() const 3721 bool HTMLMediaElement::isGestureNeededForPlayback() const
3724 { 3722 {
3725 if (!m_lockedPendingUserGesture) 3723 if (!m_lockedPendingUserGesture)
3726 return false; 3724 return false;
3727 3725
3726 if (loadType() == WebMediaPlayer::LoadTypeMediaStream)
3727 return false;
3728
3728 // We want to allow muted video to autoplay if: 3729 // We want to allow muted video to autoplay if:
3729 // - the flag is enabled; 3730 // - the flag is enabled;
3730 // - Data Saver is not enabled; 3731 // - Data Saver is not enabled;
3731 // - Autoplay is enabled in settings; 3732 // - Autoplay is enabled in settings;
3732 if (isHTMLVideoElement() 3733 if (isHTMLVideoElement()
3733 && muted() 3734 && muted()
3734 && RuntimeEnabledFeatures::autoplayMutedVideosEnabled() 3735 && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()
3735 && !(document().settings() && document().settings()->dataSaverEnabled()) 3736 && !(document().settings() && document().settings()->dataSaverEnabled())
3736 && isAutoplayAllowedPerSettings()) { 3737 && isAutoplayAllowedPerSettings()) {
3737 return false; 3738 return false;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
4023 4024
4024 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4025 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4025 { 4026 {
4026 IntRect result; 4027 IntRect result;
4027 if (LayoutObject* object = m_element->layoutObject()) 4028 if (LayoutObject* object = m_element->layoutObject())
4028 result = object->absoluteBoundingBoxRect(); 4029 result = object->absoluteBoundingBoxRect();
4029 return result; 4030 return result;
4030 } 4031 }
4031 4032
4032 } // namespace blink 4033 } // namespace blink
OLDNEW
« 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