OLD | NEW |
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 Loading... |
2285 } | 2285 } |
2286 | 2286 |
2287 void HTMLMediaElement::setMuted(bool muted) | 2287 void HTMLMediaElement::setMuted(bool muted) |
2288 { | 2288 { |
2289 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) <
< ")"; | 2289 BLINK_MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) <
< ")"; |
2290 | 2290 |
2291 if (m_muted == muted) | 2291 if (m_muted == muted) |
2292 return; | 2292 return; |
2293 | 2293 |
2294 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur
e(); | 2294 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur
e(); |
| 2295 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && m
_muted && isLockedPendingUserGesture(); |
2295 | 2296 |
2296 if (UserGestureIndicator::processingUserGesture()) | 2297 if (UserGestureIndicator::processingUserGesture()) |
2297 unlockUserGesture(); | 2298 unlockUserGesture(); |
2298 | 2299 |
2299 m_muted = muted; | 2300 m_muted = muted; |
2300 m_autoplayHelper->mutedChanged(); | 2301 m_autoplayHelper->mutedChanged(); |
2301 | 2302 |
2302 updateVolume(); | 2303 updateVolume(); |
2303 | 2304 |
2304 scheduleEvent(EventTypeNames::volumechange); | 2305 scheduleEvent(EventTypeNames::volumechange); |
2305 | 2306 |
2306 // If an element autoplayed while muted, it needs to be unlocked to unmute, | 2307 // If an element autoplayed while muted, it needs to be unlocked to unmute, |
2307 // otherwise, it will be paused. | 2308 // otherwise, it will be paused. |
2308 if (wasAutoplayingMuted) { | 2309 if (wasAutoplayingMuted) { |
2309 if (isGestureNeededForPlayback()) { | 2310 if (isGestureNeededForPlayback()) { |
2310 pause(); | 2311 pause(); |
2311 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteAction
Status::Failure); | 2312 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteAction
Status::Failure); |
2312 } else { | 2313 } else { |
2313 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteAction
Status::Success); | 2314 m_autoplayUmaHelper->recordAutoplayUnmuteStatus(AutoplayUnmuteAction
Status::Success); |
2314 } | 2315 } |
2315 } | 2316 } |
| 2317 |
| 2318 // If an element was a candidate for autoplay muted but not visible, it will |
| 2319 // have a visibility observer ready to start its playback. |
| 2320 if (wasPendingAutoplayMuted) { |
| 2321 m_autoplayVisibilityObserver->stop(); |
| 2322 m_autoplayVisibilityObserver = nullptr; |
| 2323 } |
2316 } | 2324 } |
2317 | 2325 |
2318 void HTMLMediaElement::updateVolume() | 2326 void HTMLMediaElement::updateVolume() |
2319 { | 2327 { |
2320 if (webMediaPlayer()) | 2328 if (webMediaPlayer()) |
2321 webMediaPlayer()->setVolume(effectiveMediaVolume()); | 2329 webMediaPlayer()->setVolume(effectiveMediaVolume()); |
2322 | 2330 |
2323 if (mediaControls()) | 2331 if (mediaControls()) |
2324 mediaControls()->updateVolume(); | 2332 mediaControls()->updateVolume(); |
2325 } | 2333 } |
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4013 | 4021 |
4014 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 4022 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
4015 { | 4023 { |
4016 IntRect result; | 4024 IntRect result; |
4017 if (LayoutObject* object = m_element->layoutObject()) | 4025 if (LayoutObject* object = m_element->layoutObject()) |
4018 result = object->absoluteBoundingBoxRect(); | 4026 result = object->absoluteBoundingBoxRect(); |
4019 return result; | 4027 return result; |
4020 } | 4028 } |
4021 | 4029 |
4022 } // namespace blink | 4030 } // namespace blink |
OLD | NEW |