| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 case WebMediaPlayer::PreloadMetaData: | 274 case WebMediaPlayer::PreloadMetaData: |
| 275 return "metadata"; | 275 return "metadata"; |
| 276 case WebMediaPlayer::PreloadAuto: | 276 case WebMediaPlayer::PreloadAuto: |
| 277 return "auto"; | 277 return "auto"; |
| 278 } | 278 } |
| 279 | 279 |
| 280 ASSERT_NOT_REACHED(); | 280 ASSERT_NOT_REACHED(); |
| 281 return String(); | 281 return String(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 // These values are used for histograms. Do not reorder. |
| 285 enum AutoplaySource { |
| 286 // Autoplay comes from HTMLMediaElement `autoplay` attribute. |
| 287 AutoplaySourceAttribute = 0, |
| 288 // Autoplay comes from `play()` method. |
| 289 AutoplaySourceMethod = 1, |
| 290 // This enum value must be last. |
| 291 NumberOfAutoplaySources = 2, |
| 292 }; |
| 293 |
| 284 } // anonymous namespace | 294 } // anonymous namespace |
| 285 | 295 |
| 286 class HTMLMediaElement::AutoplayHelperClientImpl : | 296 class HTMLMediaElement::AutoplayHelperClientImpl : |
| 287 public AutoplayExperimentHelper::Client { | 297 public AutoplayExperimentHelper::Client { |
| 288 | 298 |
| 289 public: | 299 public: |
| 290 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) | 300 static AutoplayHelperClientImpl* create(HTMLMediaElement* element) |
| 291 { | 301 { |
| 292 return new AutoplayHelperClientImpl(element); | 302 return new AutoplayHelperClientImpl(element); |
| 293 } | 303 } |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 | 1621 |
| 1612 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track
sAreReady) { | 1622 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track
sAreReady) { |
| 1613 if (oldState <= HAVE_CURRENT_DATA) { | 1623 if (oldState <= HAVE_CURRENT_DATA) { |
| 1614 scheduleEvent(EventTypeNames::canplay); | 1624 scheduleEvent(EventTypeNames::canplay); |
| 1615 if (isPotentiallyPlaying) | 1625 if (isPotentiallyPlaying) |
| 1616 scheduleNotifyPlaying(); | 1626 scheduleNotifyPlaying(); |
| 1617 } | 1627 } |
| 1618 | 1628 |
| 1619 // Check for autoplay, and record metrics about it if needed. | 1629 // Check for autoplay, and record metrics about it if needed. |
| 1620 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { | 1630 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { |
| 1631 recordAutoplaySourceMetric(AutoplaySourceAttribute); |
| 1621 // If the autoplay experiment says that it's okay to play now, | 1632 // If the autoplay experiment says that it's okay to play now, |
| 1622 // then don't require a user gesture. | 1633 // then don't require a user gesture. |
| 1623 m_autoplayHelper->becameReadyToPlay(); | 1634 m_autoplayHelper->becameReadyToPlay(); |
| 1624 | 1635 |
| 1625 if (!isGestureNeededForPlayback()) { | 1636 if (!isGestureNeededForPlayback()) { |
| 1626 m_paused = false; | 1637 m_paused = false; |
| 1627 invalidateCachedTime(); | 1638 invalidateCachedTime(); |
| 1628 scheduleEvent(EventTypeNames::play); | 1639 scheduleEvent(EventTypeNames::play); |
| 1629 scheduleNotifyPlaying(); | 1640 scheduleNotifyPlaying(); |
| 1630 m_autoplaying = false; | 1641 m_autoplaying = false; |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 return promise; | 2052 return promise; |
| 2042 } | 2053 } |
| 2043 | 2054 |
| 2044 Nullable<ExceptionCode> HTMLMediaElement::play() | 2055 Nullable<ExceptionCode> HTMLMediaElement::play() |
| 2045 { | 2056 { |
| 2046 DVLOG(MEDIA_LOG_LEVEL) << "play(" << (void*)this << ")"; | 2057 DVLOG(MEDIA_LOG_LEVEL) << "play(" << (void*)this << ")"; |
| 2047 | 2058 |
| 2048 m_autoplayHelper->playMethodCalled(); | 2059 m_autoplayHelper->playMethodCalled(); |
| 2049 | 2060 |
| 2050 if (!UserGestureIndicator::processingUserGesture()) { | 2061 if (!UserGestureIndicator::processingUserGesture()) { |
| 2062 recordAutoplaySourceMetric(AutoplaySourceMethod); |
| 2051 if (isGestureNeededForPlayback()) { | 2063 if (isGestureNeededForPlayback()) { |
| 2052 // If playback is deferred, then don't start playback but don't | 2064 // If playback is deferred, then don't start playback but don't |
| 2053 // fail yet either. | 2065 // fail yet either. |
| 2054 if (m_autoplayHelper->isPlaybackDeferred()) | 2066 if (m_autoplayHelper->isPlaybackDeferred()) |
| 2055 return nullptr; | 2067 return nullptr; |
| 2056 | 2068 |
| 2057 // If we're already playing, then this play would do nothing anyway. | 2069 // If we're already playing, then this play would do nothing anyway. |
| 2058 // Call playInternal to handle scheduling the promise resolution. | 2070 // Call playInternal to handle scheduling the promise resolution. |
| 2059 if (!m_paused) { | 2071 if (!m_paused) { |
| 2060 playInternal(); | 2072 playInternal(); |
| (...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3761 { | 3773 { |
| 3762 if (isHTMLVideoElement()) { | 3774 if (isHTMLVideoElement()) { |
| 3763 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Sh
ow.Video", MediaControlsShowMax)); | 3775 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Sh
ow.Video", MediaControlsShowMax)); |
| 3764 return histogram; | 3776 return histogram; |
| 3765 } | 3777 } |
| 3766 | 3778 |
| 3767 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Show.A
udio", MediaControlsShowMax)); | 3779 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("Media.Controls.Show.A
udio", MediaControlsShowMax)); |
| 3768 return histogram; | 3780 return histogram; |
| 3769 } | 3781 } |
| 3770 | 3782 |
| 3783 void HTMLMediaElement::recordAutoplaySourceMetric(int source) |
| 3784 { |
| 3785 DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Auto
play", NumberOfAutoplaySources)); |
| 3786 DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video
.Autoplay.Muted", NumberOfAutoplaySources)); |
| 3787 DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Auto
play", NumberOfAutoplaySources)); |
| 3788 |
| 3789 if (isHTMLVideoElement()) { |
| 3790 videoHistogram.count(source); |
| 3791 if (muted()) |
| 3792 mutedVideoHistogram.count(source); |
| 3793 } else { |
| 3794 audioHistogram.count(source); |
| 3795 } |
| 3796 } |
| 3797 |
| 3771 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3798 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3772 { | 3799 { |
| 3773 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { | 3800 if (!ThreadHeap::isHeapObjectAlive(m_audioSourceNode)) { |
| 3774 getAudioSourceProvider().setClient(nullptr); | 3801 getAudioSourceProvider().setClient(nullptr); |
| 3775 m_audioSourceNode = nullptr; | 3802 m_audioSourceNode = nullptr; |
| 3776 } | 3803 } |
| 3777 } | 3804 } |
| 3778 | 3805 |
| 3779 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro
vider) | 3806 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro
vider) |
| 3780 { | 3807 { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3878 | 3905 |
| 3879 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 3906 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
| 3880 { | 3907 { |
| 3881 IntRect result; | 3908 IntRect result; |
| 3882 if (LayoutObject* object = m_element->layoutObject()) | 3909 if (LayoutObject* object = m_element->layoutObject()) |
| 3883 result = object->absoluteBoundingBoxRect(); | 3910 result = object->absoluteBoundingBoxRect(); |
| 3884 return result; | 3911 return result; |
| 3885 } | 3912 } |
| 3886 | 3913 |
| 3887 } // namespace blink | 3914 } // namespace blink |
| OLD | NEW |