| 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 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 } | 2278 } |
| 2279 | 2279 |
| 2280 void HTMLMediaElement::setMuted(bool muted) | 2280 void HTMLMediaElement::setMuted(bool muted) |
| 2281 { | 2281 { |
| 2282 MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) << ")"; | 2282 MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) << ")"; |
| 2283 | 2283 |
| 2284 if (m_muted == muted) | 2284 if (m_muted == muted) |
| 2285 return; | 2285 return; |
| 2286 | 2286 |
| 2287 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur
e(); | 2287 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur
e(); |
| 2288 bool wasPendingAutoplayMuted = m_autoplayVisibilityObserver && paused() && m
_muted && isLockedPendingUserGesture(); |
| 2288 | 2289 |
| 2289 if (UserGestureIndicator::processingUserGesture()) | 2290 if (UserGestureIndicator::processingUserGesture()) |
| 2290 unlockUserGesture(); | 2291 unlockUserGesture(); |
| 2291 | 2292 |
| 2292 m_muted = muted; | 2293 m_muted = muted; |
| 2293 m_autoplayHelper->mutedChanged(); | 2294 m_autoplayHelper->mutedChanged(); |
| 2294 | 2295 |
| 2295 updateVolume(); | 2296 updateVolume(); |
| 2296 | 2297 |
| 2297 if (muted) | 2298 if (muted) |
| 2298 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute
_On")); | 2299 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute
_On")); |
| 2299 else | 2300 else |
| 2300 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute
_Off")); | 2301 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute
_Off")); |
| 2301 | 2302 |
| 2302 scheduleEvent(EventTypeNames::volumechange); | 2303 scheduleEvent(EventTypeNames::volumechange); |
| 2303 | 2304 |
| 2304 // If an element autoplayed while muted, it needs to be unlocked to unmute, | 2305 // If an element autoplayed while muted, it needs to be unlocked to unmute, |
| 2305 // otherwise, it will be paused. | 2306 // otherwise, it will be paused. |
| 2306 if (wasAutoplayingMuted) { | 2307 if (wasAutoplayingMuted) { |
| 2307 if (isGestureNeededForPlayback()) { | 2308 if (isGestureNeededForPlayback()) { |
| 2308 pause(); | 2309 pause(); |
| 2309 recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure); | 2310 recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure); |
| 2310 } else { | 2311 } else { |
| 2311 recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess); | 2312 recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess); |
| 2312 } | 2313 } |
| 2313 } | 2314 } |
| 2315 |
| 2316 // If an element was a candidate for autoplay muted but not visible, it will |
| 2317 // have a visibility observer ready to start its playback. |
| 2318 if (wasPendingAutoplayMuted) { |
| 2319 m_autoplayVisibilityObserver->stop(); |
| 2320 m_autoplayVisibilityObserver = nullptr; |
| 2321 } |
| 2314 } | 2322 } |
| 2315 | 2323 |
| 2316 void HTMLMediaElement::updateVolume() | 2324 void HTMLMediaElement::updateVolume() |
| 2317 { | 2325 { |
| 2318 if (webMediaPlayer()) | 2326 if (webMediaPlayer()) |
| 2319 webMediaPlayer()->setVolume(effectiveMediaVolume()); | 2327 webMediaPlayer()->setVolume(effectiveMediaVolume()); |
| 2320 | 2328 |
| 2321 if (mediaControls()) | 2329 if (mediaControls()) |
| 2322 mediaControls()->updateVolume(); | 2330 mediaControls()->updateVolume(); |
| 2323 } | 2331 } |
| (...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4033 | 4041 |
| 4034 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 4042 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
| 4035 { | 4043 { |
| 4036 IntRect result; | 4044 IntRect result; |
| 4037 if (LayoutObject* object = m_element->layoutObject()) | 4045 if (LayoutObject* object = m_element->layoutObject()) |
| 4038 result = object->absoluteBoundingBoxRect(); | 4046 result = object->absoluteBoundingBoxRect(); |
| 4039 return result; | 4047 return result; |
| 4040 } | 4048 } |
| 4041 | 4049 |
| 4042 } // namespace blink | 4050 } // namespace blink |
| OLD | NEW |