Chromium Code Reviews| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 , m_seeking(false) | 424 , m_seeking(false) |
| 425 , m_sentStalledEvent(false) | 425 , m_sentStalledEvent(false) |
| 426 , m_ignorePreloadNone(false) | 426 , m_ignorePreloadNone(false) |
| 427 , m_textTracksVisible(false) | 427 , m_textTracksVisible(false) |
| 428 , m_shouldPerformAutomaticTrackSelection(true) | 428 , m_shouldPerformAutomaticTrackSelection(true) |
| 429 , m_tracksAreReady(true) | 429 , m_tracksAreReady(true) |
| 430 , m_processingPreferenceChange(false) | 430 , m_processingPreferenceChange(false) |
| 431 , m_remoteRoutesAvailable(false) | 431 , m_remoteRoutesAvailable(false) |
| 432 , m_playingRemotely(false) | 432 , m_playingRemotely(false) |
| 433 , m_inOverlayFullscreenVideo(false) | 433 , m_inOverlayFullscreenVideo(false) |
| 434 , m_isAutoplayingMuted(false) | |
| 434 , m_audioTracks(AudioTrackList::create(*this)) | 435 , m_audioTracks(AudioTrackList::create(*this)) |
| 435 , m_videoTracks(VideoTrackList::create(*this)) | 436 , m_videoTracks(VideoTrackList::create(*this)) |
| 436 , m_textTracks(nullptr) | 437 , m_textTracks(nullptr) |
| 437 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolveScheduledPlayPromises)) | 438 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolveScheduledPlayPromises)) |
| 438 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectScheduledPlayPromises)) | 439 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectScheduledPlayPromises)) |
| 439 , m_audioSourceNode(nullptr) | 440 , m_audioSourceNode(nullptr) |
| 440 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) | 441 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) |
| 441 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) | 442 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) |
| 442 , m_remotePlaybackClient(nullptr) | 443 , m_remotePlaybackClient(nullptr) |
| 443 { | 444 { |
| (...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2253 | 2254 |
| 2254 bool HTMLMediaElement::muted() const | 2255 bool HTMLMediaElement::muted() const |
| 2255 { | 2256 { |
| 2256 return m_muted; | 2257 return m_muted; |
| 2257 } | 2258 } |
| 2258 | 2259 |
| 2259 void HTMLMediaElement::setMuted(bool muted) | 2260 void HTMLMediaElement::setMuted(bool muted) |
| 2260 { | 2261 { |
| 2261 DVLOG(MEDIA_LOG_LEVEL) << "setMuted(" << (void*)this << ", " << boolString(m uted) << ")"; | 2262 DVLOG(MEDIA_LOG_LEVEL) << "setMuted(" << (void*)this << ", " << boolString(m uted) << ")"; |
| 2262 | 2263 |
| 2264 if (UserGestureIndicator::processingUserGesture()) | |
| 2265 unlockUserGesture(); | |
| 2266 | |
| 2263 if (m_muted == muted) | 2267 if (m_muted == muted) |
| 2264 return; | 2268 return; |
| 2265 | 2269 |
| 2266 m_muted = muted; | 2270 m_muted = muted; |
| 2267 m_autoplayHelper->mutedChanged(); | 2271 m_autoplayHelper->mutedChanged(); |
| 2268 | 2272 |
| 2269 updateVolume(); | 2273 updateVolume(); |
| 2270 | 2274 |
| 2271 if (muted) | 2275 if (muted) |
| 2272 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _On")); | 2276 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _On")); |
| 2273 else | 2277 else |
| 2274 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off")); | 2278 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off")); |
| 2275 | 2279 |
| 2276 scheduleEvent(EventTypeNames::volumechange); | 2280 scheduleEvent(EventTypeNames::volumechange); |
| 2281 | |
| 2282 if (!muted && m_isAutoplayingMuted) { | |
|
foolip
2016/06/09 11:41:43
As per https://github.com/whatwg/html/issues/976 I
| |
| 2283 // Pause the element autoplayed muted when unmuting if there was no user gesture. | |
| 2284 if (isLockedPendingUserGesture()) | |
| 2285 pause(); | |
| 2286 m_isAutoplayingMuted = false; | |
| 2287 } | |
| 2277 } | 2288 } |
| 2278 | 2289 |
| 2279 void HTMLMediaElement::updateVolume() | 2290 void HTMLMediaElement::updateVolume() |
| 2280 { | 2291 { |
| 2281 if (webMediaPlayer()) | 2292 if (webMediaPlayer()) |
| 2282 webMediaPlayer()->setVolume(effectiveMediaVolume()); | 2293 webMediaPlayer()->setVolume(effectiveMediaVolume()); |
| 2283 | 2294 |
| 2284 if (mediaControls()) | 2295 if (mediaControls()) |
| 2285 mediaControls()->updateVolume(); | 2296 mediaControls()->updateVolume(); |
| 2286 } | 2297 } |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3664 bool HTMLMediaElement::isLockedPendingUserGesture() const | 3675 bool HTMLMediaElement::isLockedPendingUserGesture() const |
| 3665 { | 3676 { |
| 3666 return m_lockedPendingUserGesture; | 3677 return m_lockedPendingUserGesture; |
| 3667 } | 3678 } |
| 3668 | 3679 |
| 3669 void HTMLMediaElement::unlockUserGesture() | 3680 void HTMLMediaElement::unlockUserGesture() |
| 3670 { | 3681 { |
| 3671 m_lockedPendingUserGesture = false; | 3682 m_lockedPendingUserGesture = false; |
| 3672 } | 3683 } |
| 3673 | 3684 |
| 3674 bool HTMLMediaElement::isGestureNeededForPlayback() const | 3685 bool HTMLMediaElement::isGestureNeededForPlayback() |
| 3675 { | 3686 { |
| 3687 m_isAutoplayingMuted = false; | |
| 3688 | |
| 3676 if (!m_lockedPendingUserGesture) | 3689 if (!m_lockedPendingUserGesture) |
| 3677 return false; | 3690 return false; |
| 3678 | 3691 |
| 3679 if (muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) | 3692 if (muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { |
| 3693 m_isAutoplayingMuted = true; | |
| 3680 return false; | 3694 return false; |
| 3695 } | |
| 3681 | 3696 |
| 3682 if (m_autoplayHelper->isGestureRequirementOverridden()) | 3697 if (m_autoplayHelper->isGestureRequirementOverridden()) |
| 3683 return false; | 3698 return false; |
| 3684 | 3699 |
| 3685 return true; | 3700 return true; |
| 3686 } | 3701 } |
| 3687 | 3702 |
| 3688 void HTMLMediaElement::setNetworkState(NetworkState state) | 3703 void HTMLMediaElement::setNetworkState(NetworkState state) |
| 3689 { | 3704 { |
| 3690 if (m_networkState != state) { | 3705 if (m_networkState != state) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3926 | 3941 |
| 3927 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst | 3942 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst |
| 3928 { | 3943 { |
| 3929 IntRect result; | 3944 IntRect result; |
| 3930 if (LayoutObject* object = m_element->layoutObject()) | 3945 if (LayoutObject* object = m_element->layoutObject()) |
| 3931 result = object->absoluteBoundingBoxRect(); | 3946 result = object->absoluteBoundingBoxRect(); |
| 3932 return result; | 3947 return result; |
| 3933 } | 3948 } |
| 3934 | 3949 |
| 3935 } // namespace blink | 3950 } // namespace blink |
| OLD | NEW |