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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 , m_initialPlayWithoutUserGesture(false) | 340 , m_initialPlayWithoutUserGesture(false) |
341 , m_autoplayMediaCounted(false) | 341 , m_autoplayMediaCounted(false) |
342 , m_inOverlayFullscreenVideo(false) | 342 , m_inOverlayFullscreenVideo(false) |
343 , m_audioTracks(AudioTrackList::create(*this)) | 343 , m_audioTracks(AudioTrackList::create(*this)) |
344 , m_videoTracks(VideoTrackList::create(*this)) | 344 , m_videoTracks(VideoTrackList::create(*this)) |
345 , m_textTracks(nullptr) | 345 , m_textTracks(nullptr) |
346 #if ENABLE(WEB_AUDIO) | 346 #if ENABLE(WEB_AUDIO) |
347 , m_audioSourceNode(nullptr) | 347 , m_audioSourceNode(nullptr) |
348 #endif | 348 #endif |
349 , m_autoplayHelper(*this) | 349 , m_autoplayHelper(*this) |
350 , m_anyUserGestureEncountered(false) | |
351 , m_initialPlaybackRecorded(false) | |
350 { | 352 { |
351 #if ENABLE(OILPAN) | 353 #if ENABLE(OILPAN) |
352 ThreadState::current()->registerPreFinalizer(this); | 354 ThreadState::current()->registerPreFinalizer(this); |
353 #endif | 355 #endif |
354 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 356 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
355 | 357 |
356 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this); | 358 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement(%p)", this); |
357 | 359 |
358 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) | 360 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) |
359 m_userGestureRequiredForPlay = true; | 361 m_userGestureRequiredForPlay = true; |
360 | 362 |
361 setHasCustomStyleCallbacks(); | 363 setHasCustomStyleCallbacks(); |
362 addElementToDocumentMap(this, &document); | 364 addElementToDocumentMap(this, &document); |
365 recordAutoplayMetric(AnyMediaElement); | |
philipj_slow
2015/11/25 14:03:42
It's likely that this and the AnyVideoElement will
liberato (no reviews please)
2015/11/25 18:58:54
very good point, thanks.
| |
363 } | 366 } |
364 | 367 |
365 HTMLMediaElement::~HTMLMediaElement() | 368 HTMLMediaElement::~HTMLMediaElement() |
366 { | 369 { |
367 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement(%p)", this); | 370 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement(%p)", this); |
368 | 371 |
369 #if !ENABLE(OILPAN) | 372 #if !ENABLE(OILPAN) |
370 // HTMLMediaElement and m_asyncEventQueue always become unreachable | 373 // HTMLMediaElement and m_asyncEventQueue always become unreachable |
371 // together. So HTMLMediaElement and m_asyncEventQueue are destructed in | 374 // together. So HTMLMediaElement and m_asyncEventQueue are destructed in |
372 // the same GC. We don't need to close it explicitly in Oilpan. | 375 // the same GC. We don't need to close it explicitly in Oilpan. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 case WebMimeRegistry::IsSupported: | 665 case WebMimeRegistry::IsSupported: |
663 canPlay = "probably"; | 666 canPlay = "probably"; |
664 break; | 667 break; |
665 } | 668 } |
666 | 669 |
667 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%p, %s, %s) -> %s", this, mime Type.utf8().data(), keySystem.utf8().data(), canPlay.utf8().data()); | 670 WTF_LOG(Media, "HTMLMediaElement::canPlayType(%p, %s, %s) -> %s", this, mime Type.utf8().data(), keySystem.utf8().data(), canPlay.utf8().data()); |
668 | 671 |
669 return canPlay; | 672 return canPlay; |
670 } | 673 } |
671 | 674 |
672 void HTMLMediaElement::recordMetricsIfPausing() | 675 void HTMLMediaElement::recordMetricsIfPausing() |
philipj_slow
2015/11/25 14:03:42
Maybe rename to recordMetricsBeforePause() if that
liberato (no reviews please)
2015/11/25 18:58:54
Done.
| |
673 { | 676 { |
674 // If not playing, then nothing to record. | 677 // If not playing, then nothing to record. |
675 // TODO(liberato): test metrics. this was m_paused. | |
676 if (m_paused) | 678 if (m_paused) |
677 return; | 679 return; |
678 | 680 |
681 // Don't count seeking as a bailout. | |
philipj_slow
2015/11/25 14:03:42
Why was this comment added? I see no changes relat
liberato (no reviews please)
2015/11/25 18:58:54
whoops, forgot to delete.
| |
679 const bool bailout = isBailout(); | 682 const bool bailout = isBailout(); |
683 const bool ended = endedPlayback(); | |
philipj_slow
2015/11/25 14:03:42
Have you tested that this is always true when reco
liberato (no reviews please)
2015/11/25 18:58:54
it has worked in all of my tests.
however, i rath
| |
680 | 684 |
681 // Record that play was paused. We don't care if it was autoplay, | 685 // Record that play was paused. We don't care if it was autoplay, |
682 // play(), or the user manually started it. | 686 // play(), or the user manually started it. |
683 recordAutoplayMetric(AnyPlaybackPaused); | 687 recordAutoplayMetric(AnyPlaybackPaused); |
684 if (bailout) | 688 if (bailout) |
685 recordAutoplayMetric(AnyPlaybackBailout); | 689 recordAutoplayMetric(AnyPlaybackBailout); |
690 if (ended) | |
691 recordAutoplayMetric(AnyPlaybackComplete); | |
686 | 692 |
687 // If this was a gestureless play, then record that separately. | 693 // If this was a gestureless play, then record that separately. |
688 // These cover attr and play() gestureless starts. | 694 // These cover attr and play() gestureless starts. |
689 if (m_initialPlayWithoutUserGesture) { | 695 if (m_initialPlayWithoutUserGesture) { |
690 m_initialPlayWithoutUserGesture = false; | 696 m_initialPlayWithoutUserGesture = false; |
691 | 697 |
692 recordAutoplayMetric(AutoplayPaused); | 698 recordAutoplayMetric(AutoplayPaused); |
693 | 699 |
694 if (bailout) | 700 if (bailout) |
695 recordAutoplayMetric(AutoplayBailout); | 701 recordAutoplayMetric(AutoplayBailout); |
702 | |
703 if (ended) | |
704 recordAutoplayMetric(AutoplayComplete); | |
696 } | 705 } |
697 } | 706 } |
698 | 707 |
699 void HTMLMediaElement::load() | 708 void HTMLMediaElement::load() |
700 { | 709 { |
701 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this); | 710 WTF_LOG(Media, "HTMLMediaElement::load(%p)", this); |
702 | 711 |
703 recordMetricsIfPausing(); | 712 recordMetricsIfPausing(); |
713 bool gesture = UserGestureIndicator::processingUserGesture(); | |
philipj_slow
2015/11/25 14:03:42
IIUC, this and a bunch of other changes are "will
liberato (no reviews please)
2015/11/25 18:58:54
i had done exactly that, but didn't like it. i'll
| |
714 m_anyUserGestureEncountered |= gesture; | |
704 | 715 |
705 if (UserGestureIndicator::processingUserGesture() && m_userGestureRequiredFo rPlay) { | 716 if (gesture && m_userGestureRequiredForPlay) { |
706 recordAutoplayMetric(AutoplayEnabledThroughLoad); | 717 recordAutoplayMetric(AutoplayEnabledThroughLoad); |
707 m_userGestureRequiredForPlay = false; | 718 m_userGestureRequiredForPlay = false; |
708 // While usergesture-initiated load()s technically count as autoplayed, | 719 // While usergesture-initiated load()s technically count as autoplayed, |
709 // they don't feel like such to the users and hence we don't want to | 720 // they don't feel like such to the users and hence we don't want to |
710 // count them for the purposes of metrics. | 721 // count them for the purposes of metrics. |
711 m_autoplayMediaCounted = true; | 722 m_autoplayMediaCounted = true; |
712 } | 723 } |
713 | 724 |
714 prepareForLoad(); | 725 prepareForLoad(); |
715 loadInternal(); | 726 loadInternal(); |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1526 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { | 1537 if (m_readyState >= HAVE_CURRENT_DATA && oldState < HAVE_CURRENT_DATA && !m_ haveFiredLoadedData) { |
1527 m_haveFiredLoadedData = true; | 1538 m_haveFiredLoadedData = true; |
1528 shouldUpdateDisplayState = true; | 1539 shouldUpdateDisplayState = true; |
1529 scheduleEvent(EventTypeNames::loadeddata); | 1540 scheduleEvent(EventTypeNames::loadeddata); |
1530 setShouldDelayLoadEvent(false); | 1541 setShouldDelayLoadEvent(false); |
1531 } | 1542 } |
1532 | 1543 |
1533 bool isPotentiallyPlaying = potentiallyPlaying(); | 1544 bool isPotentiallyPlaying = potentiallyPlaying(); |
1534 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { | 1545 if (m_readyState == HAVE_FUTURE_DATA && oldState <= HAVE_CURRENT_DATA && tra cksAreReady) { |
1535 scheduleEvent(EventTypeNames::canplay); | 1546 scheduleEvent(EventTypeNames::canplay); |
1536 if (isPotentiallyPlaying) | 1547 if (isPotentiallyPlaying) { |
1537 scheduleEvent(EventTypeNames::playing); | 1548 scheduleEvent(EventTypeNames::playing); |
1549 recordAutoplayMetric(AnyPlaybackStarted); | |
philipj_slow
2015/11/25 14:03:41
Rather than measuring the playing event, can you p
liberato (no reviews please)
2015/11/25 18:58:54
Done.
| |
1550 } | |
1538 shouldUpdateDisplayState = true; | 1551 shouldUpdateDisplayState = true; |
1539 } | 1552 } |
1540 | 1553 |
1541 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { | 1554 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { |
1542 if (oldState <= HAVE_CURRENT_DATA) { | 1555 if (oldState <= HAVE_CURRENT_DATA) { |
1543 scheduleEvent(EventTypeNames::canplay); | 1556 scheduleEvent(EventTypeNames::canplay); |
1544 if (isPotentiallyPlaying) | 1557 if (isPotentiallyPlaying) { |
1545 scheduleEvent(EventTypeNames::playing); | 1558 scheduleEvent(EventTypeNames::playing); |
1559 recordAutoplayMetric(AnyPlaybackStarted); | |
1560 } | |
1546 } | 1561 } |
1547 | 1562 |
1548 // Check for autoplay, and record metrics about it if needed. | 1563 // Check for autoplay, and record metrics about it if needed. |
1549 if (shouldAutoplay(RecordMetricsBehavior::DoRecord)) { | 1564 if (shouldAutoplay(RecordMetricsBehavior::RecordOnSandboxFailure)) { |
1550 // If the autoplay experiment says that it's okay to play now, | 1565 // If the autoplay experiment says that it's okay to play now, |
1551 // then don't require a user gesture. | 1566 // then don't require a user gesture. |
1552 m_autoplayHelper.becameReadyToPlay(); | 1567 m_autoplayHelper.becameReadyToPlay(); |
1553 | 1568 |
1569 // Record that autoplay media was encountered, but wait until | |
philipj_slow
2015/11/25 14:03:41
I don't quite understand this comment. Is it expla
liberato (no reviews please)
2015/11/25 18:58:54
yes. i'll update the comment to make it clearer.
| |
1570 // after the autoplay experiment helper has had a chance to update | |
1571 // the user gesture requirement. This is because aME() tries to | |
1572 // guess whether the play will succeed based on that. | |
1573 autoplayMediaEncountered(); | |
1574 | |
1554 if (!m_userGestureRequiredForPlay) { | 1575 if (!m_userGestureRequiredForPlay) { |
1555 m_paused = false; | 1576 m_paused = false; |
1556 invalidateCachedTime(); | 1577 invalidateCachedTime(); |
1557 scheduleEvent(EventTypeNames::play); | 1578 scheduleEvent(EventTypeNames::play); |
1558 scheduleEvent(EventTypeNames::playing); | 1579 scheduleEvent(EventTypeNames::playing); |
1580 recordAutoplayMetric(AnyPlaybackStarted); | |
1559 } | 1581 } |
1560 } | 1582 } |
1561 | 1583 |
1562 scheduleEvent(EventTypeNames::canplaythrough); | 1584 scheduleEvent(EventTypeNames::canplaythrough); |
1563 | 1585 |
1564 shouldUpdateDisplayState = true; | 1586 shouldUpdateDisplayState = true; |
1565 } | 1587 } |
1566 | 1588 |
1567 if (shouldUpdateDisplayState) { | 1589 if (shouldUpdateDisplayState) { |
1568 updateDisplayState(); | 1590 updateDisplayState(); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1863 } | 1885 } |
1864 | 1886 |
1865 bool HTMLMediaElement::autoplay() const | 1887 bool HTMLMediaElement::autoplay() const |
1866 { | 1888 { |
1867 return fastHasAttribute(autoplayAttr); | 1889 return fastHasAttribute(autoplayAttr); |
1868 } | 1890 } |
1869 | 1891 |
1870 bool HTMLMediaElement::shouldAutoplay(const RecordMetricsBehavior recordMetrics) | 1892 bool HTMLMediaElement::shouldAutoplay(const RecordMetricsBehavior recordMetrics) |
1871 { | 1893 { |
1872 if (m_autoplaying && m_paused && autoplay()) { | 1894 if (m_autoplaying && m_paused && autoplay()) { |
1873 if (recordMetrics == RecordMetricsBehavior::DoRecord) | |
1874 autoplayMediaEncountered(); | |
1875 | |
1876 if (document().isSandboxed(SandboxAutomaticFeatures)) { | 1895 if (document().isSandboxed(SandboxAutomaticFeatures)) { |
1877 if (recordMetrics == RecordMetricsBehavior::DoRecord) | 1896 if (recordMetrics == RecordMetricsBehavior::RecordOnSandboxFailure) { |
1897 // We record autoplayMediaEncountered here because we know | |
1898 // that the autoplay attempt will fail. | |
1899 autoplayMediaEncountered(); | |
1878 recordAutoplayMetric(AutoplayDisabledBySandbox); | 1900 recordAutoplayMetric(AutoplayDisabledBySandbox); |
1901 } | |
1879 return false; | 1902 return false; |
1880 } | 1903 } |
1881 | 1904 |
1882 return true; | 1905 return true; |
1883 } | 1906 } |
1884 | 1907 |
1885 return false; | 1908 return false; |
1886 } | 1909 } |
1887 | 1910 |
1888 String HTMLMediaElement::preload() const | 1911 String HTMLMediaElement::preload() const |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1945 { | 1968 { |
1946 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); | 1969 return autoplay() ? WebMediaPlayer::PreloadAuto : preloadType(); |
1947 } | 1970 } |
1948 | 1971 |
1949 void HTMLMediaElement::play() | 1972 void HTMLMediaElement::play() |
1950 { | 1973 { |
1951 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); | 1974 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); |
1952 | 1975 |
1953 m_autoplayHelper.playMethodCalled(); | 1976 m_autoplayHelper.playMethodCalled(); |
1954 | 1977 |
1955 if (!UserGestureIndicator::processingUserGesture()) { | 1978 bool gesture = UserGestureIndicator::processingUserGesture(); |
1979 m_anyUserGestureEncountered |= gesture; | |
1980 | |
1981 if (!gesture) { | |
1956 autoplayMediaEncountered(); | 1982 autoplayMediaEncountered(); |
1957 | 1983 |
1958 if (m_userGestureRequiredForPlay) { | 1984 if (m_userGestureRequiredForPlay) { |
1959 recordAutoplayMetric(PlayMethodFailed); | 1985 recordAutoplayMetric(PlayMethodFailed); |
1960 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); | 1986 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); |
1961 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); | 1987 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
1962 return; | 1988 return; |
1963 } | 1989 } |
1964 } else if (m_userGestureRequiredForPlay) { | 1990 } else if (m_userGestureRequiredForPlay) { |
1965 if (m_autoplayMediaCounted) | 1991 if (m_autoplayMediaCounted) |
(...skipping 16 matching lines...) Expand all Loading... | |
1982 // is ignored to seek back to start in case loop was set after playback | 2008 // is ignored to seek back to start in case loop was set after playback |
1983 // ended. See http://crbug.com/364442 | 2009 // ended. See http://crbug.com/364442 |
1984 if (endedPlayback(LoopCondition::Ignored)) | 2010 if (endedPlayback(LoopCondition::Ignored)) |
1985 seek(0); | 2011 seek(0); |
1986 | 2012 |
1987 if (m_paused) { | 2013 if (m_paused) { |
1988 m_paused = false; | 2014 m_paused = false; |
1989 invalidateCachedTime(); | 2015 invalidateCachedTime(); |
1990 scheduleEvent(EventTypeNames::play); | 2016 scheduleEvent(EventTypeNames::play); |
1991 | 2017 |
1992 if (m_readyState <= HAVE_CURRENT_DATA) | 2018 if (m_readyState <= HAVE_CURRENT_DATA) { |
1993 scheduleEvent(EventTypeNames::waiting); | 2019 scheduleEvent(EventTypeNames::waiting); |
1994 else if (m_readyState >= HAVE_FUTURE_DATA) | 2020 } else if (m_readyState >= HAVE_FUTURE_DATA) { |
1995 scheduleEvent(EventTypeNames::playing); | 2021 scheduleEvent(EventTypeNames::playing); |
2022 recordAutoplayMetric(AnyPlaybackStarted); | |
philipj_slow
2015/11/25 14:03:42
Can you put this right after the webMediaPlayer()-
liberato (no reviews please)
2015/11/25 18:58:54
Done, and a third case as well.
| |
2023 } | |
1996 } | 2024 } |
1997 m_autoplaying = false; | 2025 m_autoplaying = false; |
1998 | 2026 |
1999 updatePlayState(); | 2027 updatePlayState(); |
2000 } | 2028 } |
2001 | 2029 |
2002 void HTMLMediaElement::autoplayMediaEncountered() | 2030 void HTMLMediaElement::autoplayMediaEncountered() |
2003 { | 2031 { |
2004 if (!m_autoplayMediaCounted) { | 2032 if (!m_autoplayMediaCounted) { |
2005 m_autoplayMediaCounted = true; | 2033 m_autoplayMediaCounted = true; |
2006 recordAutoplayMetric(AutoplayMediaFound); | 2034 recordAutoplayMetric(AutoplayMediaFound); |
2007 | 2035 |
2036 // If no user gesture was required, then assume that playback will | |
philipj_slow
2015/11/25 14:03:42
When you spell it out it's kind of weird. If you k
liberato (no reviews please)
2015/11/25 18:58:54
i'm not sure that it gets any better. wmp->play()
| |
2037 // actually start. | |
2008 if (!m_userGestureRequiredForPlay) | 2038 if (!m_userGestureRequiredForPlay) |
2009 m_initialPlayWithoutUserGesture = true; | 2039 m_initialPlayWithoutUserGesture = true; |
2010 } | 2040 } |
2011 } | 2041 } |
2012 | 2042 |
2013 bool HTMLMediaElement::isBailout() const | 2043 bool HTMLMediaElement::isBailout() const |
2014 { | 2044 { |
2015 // We count the user as having bailed-out on the video if they watched | 2045 // We count the user as having bailed-out on the video if they watched |
2016 // less than one minute and less than 50% of it. | 2046 // less than one minute and less than 50% of it. |
2017 const double playedTime = currentTime(); | 2047 const double playedTime = currentTime(); |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2717 // If the media element has a loop attribute specified | 2747 // If the media element has a loop attribute specified |
2718 if (loop()) { | 2748 if (loop()) { |
2719 m_sentEndEvent = false; | 2749 m_sentEndEvent = false; |
2720 // then seek to the earliest possible position of the media resourc e and abort these steps. | 2750 // then seek to the earliest possible position of the media resourc e and abort these steps. |
2721 seek(0); | 2751 seek(0); |
2722 } else { | 2752 } else { |
2723 // If the media element has still ended playback, and the direction of playback is still | 2753 // If the media element has still ended playback, and the direction of playback is still |
2724 // forwards, and paused is false, | 2754 // forwards, and paused is false, |
2725 if (!m_paused) { | 2755 if (!m_paused) { |
2726 // changes paused to true and fires a simple event named pause a t the media element. | 2756 // changes paused to true and fires a simple event named pause a t the media element. |
2757 recordMetricsIfPausing(); | |
2727 m_paused = true; | 2758 m_paused = true; |
2728 scheduleEvent(EventTypeNames::pause); | 2759 scheduleEvent(EventTypeNames::pause); |
2729 } | 2760 } |
2730 // Queue a task to fire a simple event named ended at the media elem ent. | 2761 // Queue a task to fire a simple event named ended at the media elem ent. |
2731 if (!m_sentEndEvent) { | 2762 if (!m_sentEndEvent) { |
2732 m_sentEndEvent = true; | 2763 m_sentEndEvent = true; |
2733 scheduleEvent(EventTypeNames::ended); | 2764 scheduleEvent(EventTypeNames::ended); |
2734 } | 2765 } |
2735 recordMetricsIfPausing(); | |
2736 } | 2766 } |
2737 } else { | 2767 } else { |
2738 m_sentEndEvent = false; | 2768 m_sentEndEvent = false; |
2739 } | 2769 } |
2740 | 2770 |
2741 updatePlayState(); | 2771 updatePlayState(); |
2742 } | 2772 } |
2743 | 2773 |
2744 void HTMLMediaElement::durationChanged() | 2774 void HTMLMediaElement::durationChanged() |
2745 { | 2775 { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2932 if (shouldBePlaying) { | 2962 if (shouldBePlaying) { |
2933 setDisplayMode(Video); | 2963 setDisplayMode(Video); |
2934 invalidateCachedTime(); | 2964 invalidateCachedTime(); |
2935 | 2965 |
2936 if (!isPlaying) { | 2966 if (!isPlaying) { |
2937 // Set rate, muted before calling play in case they were set before the media engine was setup. | 2967 // Set rate, muted before calling play in case they were set before the media engine was setup. |
2938 // The media engine should just stash the rate and muted values sinc e it isn't already playing. | 2968 // The media engine should just stash the rate and muted values sinc e it isn't already playing. |
2939 webMediaPlayer()->setRate(playbackRate()); | 2969 webMediaPlayer()->setRate(playbackRate()); |
2940 updateVolume(); | 2970 updateVolume(); |
2941 webMediaPlayer()->play(); | 2971 webMediaPlayer()->play(); |
2972 | |
2973 if (!m_initialPlaybackRecorded) { | |
philipj_slow
2015/11/25 14:03:42
I believe this is also to "give us an idea about h
liberato (no reviews please)
2015/11/25 18:58:54
the load call is part of it.
another part of the
| |
2974 bool gesture = UserGestureIndicator::processingUserGesture(); | |
2975 recordAutoplayMetric(gesture | |
2976 ? InitialPlayDuringUserGesture | |
2977 : InitialPlayNotDuringUserGesture); | |
2978 | |
2979 m_anyUserGestureEncountered |= gesture; | |
2980 recordAutoplayMetric(m_anyUserGestureEncountered | |
2981 ? InitialPlayWithUserGesture | |
2982 : InitialPlayWithoutUserGesture); | |
2983 m_initialPlaybackRecorded = true; | |
2984 } | |
2942 } | 2985 } |
2943 | 2986 |
2944 if (mediaControls()) | 2987 if (mediaControls()) |
2945 mediaControls()->playbackStarted(); | 2988 mediaControls()->playbackStarted(); |
2946 startPlaybackProgressTimer(); | 2989 startPlaybackProgressTimer(); |
2947 m_playing = true; | 2990 m_playing = true; |
2948 recordAutoplayMetric(AnyPlaybackStarted); | |
2949 | 2991 |
2950 } else { // Should not be playing right now | 2992 } else { // Should not be playing right now |
2951 if (isPlaying) | 2993 if (isPlaying) |
2952 webMediaPlayer()->pause(); | 2994 webMediaPlayer()->pause(); |
2995 | |
2953 refreshCachedTime(); | 2996 refreshCachedTime(); |
2954 | 2997 |
2955 m_playbackProgressTimer.stop(); | 2998 m_playbackProgressTimer.stop(); |
2956 m_playing = false; | 2999 m_playing = false; |
2957 double time = currentTime(); | 3000 double time = currentTime(); |
2958 if (time > m_lastSeekTime) | 3001 if (time > m_lastSeekTime) |
2959 addPlayedRange(m_lastSeekTime, time); | 3002 addPlayedRange(m_lastSeekTime, time); |
2960 | 3003 |
2961 if (couldPlayIfEnoughData()) | 3004 if (couldPlayIfEnoughData()) |
2962 prepareToPlay(); | 3005 prepareToPlay(); |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3573 bool HTMLMediaElement::isUserGestureRequiredForPlay() const | 3616 bool HTMLMediaElement::isUserGestureRequiredForPlay() const |
3574 { | 3617 { |
3575 return m_userGestureRequiredForPlay; | 3618 return m_userGestureRequiredForPlay; |
3576 } | 3619 } |
3577 | 3620 |
3578 void HTMLMediaElement::removeUserGestureRequirement() | 3621 void HTMLMediaElement::removeUserGestureRequirement() |
3579 { | 3622 { |
3580 m_userGestureRequiredForPlay = false; | 3623 m_userGestureRequiredForPlay = false; |
3581 } | 3624 } |
3582 | 3625 |
3583 void HTMLMediaElement::setInitialPlayWithoutUserGestures(bool value) | |
3584 { | |
3585 m_initialPlayWithoutUserGesture = value; | |
3586 } | |
3587 | |
3588 void HTMLMediaElement::setNetworkState(NetworkState state) | 3626 void HTMLMediaElement::setNetworkState(NetworkState state) |
3589 { | 3627 { |
3590 if (m_networkState != state) { | 3628 if (m_networkState != state) { |
3591 m_networkState = state; | 3629 m_networkState = state; |
3592 if (MediaControls* controls = mediaControls()) | 3630 if (MediaControls* controls = mediaControls()) |
3593 controls->networkStateChanged(); | 3631 controls->networkStateChanged(); |
3594 } | 3632 } |
3595 } | 3633 } |
3596 | 3634 |
3597 void HTMLMediaElement::notifyPositionMayHaveChanged(const IntRect& visibleRect) | 3635 void HTMLMediaElement::notifyPositionMayHaveChanged(const IntRect& visibleRect) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3672 visitor->trace(m_client); | 3710 visitor->trace(m_client); |
3673 } | 3711 } |
3674 | 3712 |
3675 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3713 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
3676 { | 3714 { |
3677 visitor->trace(m_client); | 3715 visitor->trace(m_client); |
3678 } | 3716 } |
3679 #endif | 3717 #endif |
3680 | 3718 |
3681 } | 3719 } |
OLD | NEW |