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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2251073003: Pretend the video has no audio track if it is playing as part of autoplay muted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 2 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
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 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 !paused() && m_muted && isLockedPendingUserGesture(); 2285 !paused() && m_muted && isLockedPendingUserGesture();
2286 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && 2286 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() &&
2287 m_muted && isLockedPendingUserGesture(); 2287 m_muted && isLockedPendingUserGesture();
2288 2288
2289 if (UserGestureIndicator::processingUserGesture()) 2289 if (UserGestureIndicator::processingUserGesture())
2290 unlockUserGesture(); 2290 unlockUserGesture();
2291 2291
2292 m_muted = muted; 2292 m_muted = muted;
2293 m_autoplayHelper->mutedChanged(); 2293 m_autoplayHelper->mutedChanged();
2294 2294
2295 updateVolume();
2296
2297 scheduleEvent(EventTypeNames::volumechange);
2298
2299 // If an element autoplayed while muted, it needs to be unlocked to unmute, 2295 // If an element autoplayed while muted, it needs to be unlocked to unmute,
2300 // otherwise, it will be paused. 2296 // otherwise, it will be paused.
2301 if (wasAutoplayingMuted) { 2297 if (wasAutoplayingMuted) {
2302 if (isGestureNeededForPlayback()) { 2298 if (isGestureNeededForPlayback()) {
2303 pause(); 2299 pause();
2304 m_autoplayUmaHelper->recordAutoplayUnmuteStatus( 2300 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(
2305 AutoplayUnmuteActionStatus::Failure); 2301 AutoplayUnmuteActionStatus::Failure);
2306 } else { 2302 } else {
2307 m_autoplayUmaHelper->recordAutoplayUnmuteStatus( 2303 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(
2308 AutoplayUnmuteActionStatus::Success); 2304 AutoplayUnmuteActionStatus::Success);
2309 } 2305 }
2310 } 2306 }
2311 2307
2308 updateVolume();
2309
2310 scheduleEvent(EventTypeNames::volumechange);
foolip 2016/10/10 11:33:07 This will change the order of events from volumech
mlamouri (slow - plz ping) 2016/10/31 15:27:41 Just to clarify, do you want me to revert the chan
foolip 2016/11/01 16:12:21 Maintaining the event order seems best, yeah.
2311
2312 // If an element was a candidate for autoplay muted but not visible, it will 2312 // If an element was a candidate for autoplay muted but not visible, it will
2313 // have a visibility observer ready to start its playback. 2313 // have a visibility observer ready to start its playback.
2314 if (wasPendingAutoplayMuted) { 2314 if (wasPendingAutoplayMuted) {
2315 m_autoplayVisibilityObserver->stop(); 2315 m_autoplayVisibilityObserver->stop();
2316 m_autoplayVisibilityObserver = nullptr; 2316 m_autoplayVisibilityObserver = nullptr;
2317 } 2317 }
2318 } 2318 }
2319 2319
2320 void HTMLMediaElement::updateVolume() { 2320 void HTMLMediaElement::updateVolume() {
2321 if (webMediaPlayer()) 2321 if (webMediaPlayer())
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 mediaControls()->stoppedCasting(); 3011 mediaControls()->stoppedCasting();
3012 if (remotePlaybackClient()) 3012 if (remotePlaybackClient())
3013 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnected); 3013 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnected);
3014 } 3014 }
3015 3015
3016 void HTMLMediaElement::cancelledRemotePlaybackRequest() { 3016 void HTMLMediaElement::cancelledRemotePlaybackRequest() {
3017 if (remotePlaybackClient()) 3017 if (remotePlaybackClient())
3018 remotePlaybackClient()->promptCancelled(); 3018 remotePlaybackClient()->promptCancelled();
3019 } 3019 }
3020 3020
3021 bool HTMLMediaElement::isAutoplayingMuted() {
3022 if (!isHTMLVideoElement() ||
3023 !RuntimeEnabledFeatures::autoplayMutedVideosEnabled())
3024 return false;
3025
3026 return muted() && isLockedPendingUserGesture();
foolip 2016/10/10 11:33:07 This will return true even if not actually playing
mlamouri (slow - plz ping) 2016/10/31 15:27:41 That was on purpose but I've added a check to make
3027 }
3028
3021 void HTMLMediaElement::requestReload(const WebURL& newUrl) { 3029 void HTMLMediaElement::requestReload(const WebURL& newUrl) {
3022 DCHECK(webMediaPlayer()); 3030 DCHECK(webMediaPlayer());
3023 DCHECK(!m_srcObject); 3031 DCHECK(!m_srcObject);
3024 DCHECK(newUrl.isValid()); 3032 DCHECK(newUrl.isValid());
3025 DCHECK(isSafeToLoadURL(newUrl, Complain)); 3033 DCHECK(isSafeToLoadURL(newUrl, Complain));
3026 resetMediaPlayerAndMediaSource(); 3034 resetMediaPlayerAndMediaSource();
3027 startPlayerLoad(newUrl); 3035 startPlayerLoad(newUrl);
3028 } 3036 }
3029 3037
3030 // MediaPlayerPresentation methods 3038 // MediaPlayerPresentation methods
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
3990 3998
3991 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() 3999 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect()
3992 const { 4000 const {
3993 IntRect result; 4001 IntRect result;
3994 if (LayoutObject* object = m_element->layoutObject()) 4002 if (LayoutObject* object = m_element->layoutObject())
3995 result = object->absoluteBoundingBoxRect(); 4003 result = object->absoluteBoundingBoxRect();
3996 return result; 4004 return result;
3997 } 4005 }
3998 4006
3999 } // namespace blink 4007 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | third_party/WebKit/public/platform/WebMediaPlayerClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698