| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 return m_muted; | 2346 return m_muted; |
| 2347 } | 2347 } |
| 2348 | 2348 |
| 2349 void HTMLMediaElement::setMuted(bool muted) { | 2349 void HTMLMediaElement::setMuted(bool muted) { |
| 2350 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) | 2350 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) |
| 2351 << ")"; | 2351 << ")"; |
| 2352 | 2352 |
| 2353 if (m_muted == muted) | 2353 if (m_muted == muted) |
| 2354 return; | 2354 return; |
| 2355 | 2355 |
| 2356 bool wasAutoplayingMuted = | 2356 bool wasAutoplayingMuted = isAutoplayingMuted(); |
| 2357 !paused() && m_muted && isLockedPendingUserGesture(); | |
| 2358 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && | 2357 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && |
| 2359 m_muted && isLockedPendingUserGesture(); | 2358 m_muted && isLockedPendingUserGesture(); |
| 2360 | 2359 |
| 2361 if (UserGestureIndicator::processingUserGesture()) | 2360 if (UserGestureIndicator::processingUserGesture()) |
| 2362 unlockUserGesture(); | 2361 unlockUserGesture(); |
| 2363 | 2362 |
| 2364 m_muted = muted; | 2363 m_muted = muted; |
| 2365 m_autoplayHelper->mutedChanged(); | 2364 m_autoplayHelper->mutedChanged(); |
| 2366 | 2365 |
| 2367 updateVolume(); | |
| 2368 | |
| 2369 scheduleEvent(EventTypeNames::volumechange); | 2366 scheduleEvent(EventTypeNames::volumechange); |
| 2370 | 2367 |
| 2371 // If an element autoplayed while muted, it needs to be unlocked to unmute, | 2368 // If an element autoplayed while muted, it needs to be unlocked to unmute, |
| 2372 // otherwise, it will be paused. | 2369 // otherwise, it will be paused. |
| 2373 if (wasAutoplayingMuted) { | 2370 if (wasAutoplayingMuted) { |
| 2374 if (isGestureNeededForPlayback()) { | 2371 if (isGestureNeededForPlayback()) { |
| 2375 pause(); | 2372 pause(); |
| 2376 m_autoplayUmaHelper->recordAutoplayUnmuteStatus( | 2373 m_autoplayUmaHelper->recordAutoplayUnmuteStatus( |
| 2377 AutoplayUnmuteActionStatus::Failure); | 2374 AutoplayUnmuteActionStatus::Failure); |
| 2378 } else { | 2375 } else { |
| 2379 m_autoplayUmaHelper->recordAutoplayUnmuteStatus( | 2376 m_autoplayUmaHelper->recordAutoplayUnmuteStatus( |
| 2380 AutoplayUnmuteActionStatus::Success); | 2377 AutoplayUnmuteActionStatus::Success); |
| 2381 } | 2378 } |
| 2382 } | 2379 } |
| 2383 | 2380 |
| 2381 // This is called after the volumechange event to make sure isAutoplayingMuted |
| 2382 // returns the right value when webMediaPlayer receives the volume update. |
| 2383 updateVolume(); |
| 2384 |
| 2384 // If an element was a candidate for autoplay muted but not visible, it will | 2385 // If an element was a candidate for autoplay muted but not visible, it will |
| 2385 // have a visibility observer ready to start its playback. | 2386 // have a visibility observer ready to start its playback. |
| 2386 if (wasPendingAutoplayMuted) { | 2387 if (wasPendingAutoplayMuted) { |
| 2387 m_autoplayVisibilityObserver->stop(); | 2388 m_autoplayVisibilityObserver->stop(); |
| 2388 m_autoplayVisibilityObserver = nullptr; | 2389 m_autoplayVisibilityObserver = nullptr; |
| 2389 } | 2390 } |
| 2390 } | 2391 } |
| 2391 | 2392 |
| 2392 void HTMLMediaElement::updateVolume() { | 2393 void HTMLMediaElement::updateVolume() { |
| 2393 if (webMediaPlayer()) | 2394 if (webMediaPlayer()) |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3102 mediaControls()->stoppedCasting(); | 3103 mediaControls()->stoppedCasting(); |
| 3103 if (remotePlaybackClient()) | 3104 if (remotePlaybackClient()) |
| 3104 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnected); | 3105 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Disconnected); |
| 3105 } | 3106 } |
| 3106 | 3107 |
| 3107 void HTMLMediaElement::cancelledRemotePlaybackRequest() { | 3108 void HTMLMediaElement::cancelledRemotePlaybackRequest() { |
| 3108 if (remotePlaybackClient()) | 3109 if (remotePlaybackClient()) |
| 3109 remotePlaybackClient()->promptCancelled(); | 3110 remotePlaybackClient()->promptCancelled(); |
| 3110 } | 3111 } |
| 3111 | 3112 |
| 3113 bool HTMLMediaElement::isAutoplayingMuted() { |
| 3114 if (!isHTMLVideoElement() || |
| 3115 !RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { |
| 3116 return false; |
| 3117 } |
| 3118 |
| 3119 return !paused() && muted() && isLockedPendingUserGesture(); |
| 3120 } |
| 3121 |
| 3112 void HTMLMediaElement::requestReload(const WebURL& newUrl) { | 3122 void HTMLMediaElement::requestReload(const WebURL& newUrl) { |
| 3113 DCHECK(webMediaPlayer()); | 3123 DCHECK(webMediaPlayer()); |
| 3114 DCHECK(!m_srcObject); | 3124 DCHECK(!m_srcObject); |
| 3115 DCHECK(newUrl.isValid()); | 3125 DCHECK(newUrl.isValid()); |
| 3116 DCHECK(isSafeToLoadURL(newUrl, Complain)); | 3126 DCHECK(isSafeToLoadURL(newUrl, Complain)); |
| 3117 resetMediaPlayerAndMediaSource(); | 3127 resetMediaPlayerAndMediaSource(); |
| 3118 startPlayerLoad(newUrl); | 3128 startPlayerLoad(newUrl); |
| 3119 } | 3129 } |
| 3120 | 3130 |
| 3121 // MediaPlayerPresentation methods | 3131 // MediaPlayerPresentation methods |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4092 | 4102 |
| 4093 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() | 4103 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() |
| 4094 const { | 4104 const { |
| 4095 IntRect result; | 4105 IntRect result; |
| 4096 if (LayoutObject* object = m_element->layoutObject()) | 4106 if (LayoutObject* object = m_element->layoutObject()) |
| 4097 result = object->absoluteBoundingBoxRect(); | 4107 result = object->absoluteBoundingBoxRect(); |
| 4098 return result; | 4108 return result; |
| 4099 } | 4109 } |
| 4100 | 4110 |
| 4101 } // namespace blink | 4111 } // namespace blink |
| OLD | NEW |