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 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef HTMLMediaElement_h | 26 #ifndef HTMLMediaElement_h |
27 #define HTMLMediaElement_h | 27 #define HTMLMediaElement_h |
28 | 28 |
29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
31 #include "core/events/GenericEventQueue.h" | 31 #include "core/events/GenericEventQueue.h" |
32 #include "core/html/AutoplayExperimentHelper.h" | |
32 #include "core/html/HTMLElement.h" | 33 #include "core/html/HTMLElement.h" |
33 #include "core/html/track/TextTrack.h" | 34 #include "core/html/track/TextTrack.h" |
34 #include "platform/Supplementable.h" | 35 #include "platform/Supplementable.h" |
35 #include "public/platform/WebMediaPlayerClient.h" | 36 #include "public/platform/WebMediaPlayerClient.h" |
36 #include "public/platform/WebMimeRegistry.h" | 37 #include "public/platform/WebMimeRegistry.h" |
37 | 38 |
38 #if ENABLE(WEB_AUDIO) | 39 #if ENABLE(WEB_AUDIO) |
39 #include "platform/audio/AudioSourceProvider.h" | 40 #include "platform/audio/AudioSourceProvider.h" |
40 #include "public/platform/WebAudioSourceProviderClient.h" | 41 #include "public/platform/WebAudioSourceProviderClient.h" |
41 #endif | 42 #endif |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 void executeDeferredLoad(); | 384 void executeDeferredLoad(); |
384 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 385 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
385 | 386 |
386 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; | 387 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; |
387 | 388 |
388 void markCaptionAndSubtitleTracksAsUnconfigured(); | 389 void markCaptionAndSubtitleTracksAsUnconfigured(); |
389 | 390 |
390 // This does not check user gesture restrictions. | 391 // This does not check user gesture restrictions. |
391 void playInternal(); | 392 void playInternal(); |
392 | 393 |
393 void gesturelessInitialPlayHalted(); | 394 // If we are about to enter a stopped state, call this to record |
philipj_slow
2015/08/13 10:15:40
s/stop/pause/, media elements don't really have a
liberato (no reviews please)
2015/09/01 06:54:20
updated, and the metric names. was trying not to
| |
395 // autoplay metrics. If we were already in a stopped state, then | |
396 // this does nothing. | |
397 void recordMetricsIfStopping(); | |
398 // Could stopping at this point be considered a bailout of playback? | |
399 // (as in, "The user really didn't want to play this"). | |
400 bool isBailout() const; | |
394 void autoplayMediaEncountered(); | 401 void autoplayMediaEncountered(); |
395 void allowVideoRendering(); | 402 void allowVideoRendering(); |
396 | 403 |
397 void updateVolume(); | 404 void updateVolume(); |
398 void updatePlayState(); | 405 void updatePlayState(); |
399 bool potentiallyPlaying() const; | 406 bool potentiallyPlaying() const; |
400 bool stoppedDueToErrors() const; | 407 bool stoppedDueToErrors() const; |
401 bool couldPlayIfEnoughData() const; | 408 bool couldPlayIfEnoughData() const; |
402 | 409 |
403 // Generally the presence of the loop attribute should be considered to mean playback | 410 // Generally the presence of the loop attribute should be considered to mean playback |
(...skipping 15 matching lines...) Expand all Loading... | |
419 | 426 |
420 void changeNetworkStateFromLoadingToIdle(); | 427 void changeNetworkStateFromLoadingToIdle(); |
421 | 428 |
422 const AtomicString& mediaGroup() const; | 429 const AtomicString& mediaGroup() const; |
423 void setMediaGroup(const AtomicString&); | 430 void setMediaGroup(const AtomicString&); |
424 void updateMediaController(); | 431 void updateMediaController(); |
425 bool isBlocked() const; | 432 bool isBlocked() const; |
426 bool isBlockedOnMediaController() const; | 433 bool isBlockedOnMediaController() const; |
427 bool isAutoplaying() const { return m_autoplaying; } | 434 bool isAutoplaying() const { return m_autoplaying; } |
428 | 435 |
436 void recordAutoplayMetric(AutoplayMetrics); | |
437 | |
429 WebMediaPlayer::CORSMode corsMode() const; | 438 WebMediaPlayer::CORSMode corsMode() const; |
430 | 439 |
431 // Returns the "direction of playback" value as specified in the HTML5 spec. | 440 // Returns the "direction of playback" value as specified in the HTML5 spec. |
432 enum DirectionOfPlayback { Backward, Forward }; | 441 enum DirectionOfPlayback { Backward, Forward }; |
433 DirectionOfPlayback directionOfPlayback() const; | 442 DirectionOfPlayback directionOfPlayback() const; |
434 | 443 |
435 // Returns the "effective playback rate" value as specified in the HTML5 spe c. | 444 // Returns the "effective playback rate" value as specified in the HTML5 spe c. |
436 double effectivePlaybackRate() const; | 445 double effectivePlaybackRate() const; |
437 | 446 |
438 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects | 447 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects |
439 // advertise they have audio and/or video, but don't explicitly signal them via | 448 // advertise they have audio and/or video, but don't explicitly signal them via |
440 // addAudioTrack() and addVideoTrack(). | 449 // addAudioTrack() and addVideoTrack(). |
441 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. | 450 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. |
442 void createPlaceholderTracksIfNecessary(); | 451 void createPlaceholderTracksIfNecessary(); |
443 | 452 |
444 // Sets the selected/enabled tracks if they aren't set before we initially | 453 // Sets the selected/enabled tracks if they aren't set before we initially |
445 // transition to HAVE_METADATA. | 454 // transition to HAVE_METADATA. |
446 void selectInitialTracksIfNecessary(); | 455 void selectInitialTracksIfNecessary(); |
447 | 456 |
457 // Return true if and only if we require a user gesture before letting | |
458 // the media play. | |
459 bool isUserGestureRequiredForPlay() const; | |
460 void removeUserGestureRequirement(); | |
461 void setInitialPlayWithoutUserGestures(bool); | |
462 | |
448 void audioTracksTimerFired(Timer<HTMLMediaElement>*); | 463 void audioTracksTimerFired(Timer<HTMLMediaElement>*); |
449 | 464 |
450 Timer<HTMLMediaElement> m_loadTimer; | 465 Timer<HTMLMediaElement> m_loadTimer; |
451 Timer<HTMLMediaElement> m_progressEventTimer; | 466 Timer<HTMLMediaElement> m_progressEventTimer; |
452 Timer<HTMLMediaElement> m_playbackProgressTimer; | 467 Timer<HTMLMediaElement> m_playbackProgressTimer; |
453 Timer<HTMLMediaElement> m_audioTracksTimer; | 468 Timer<HTMLMediaElement> m_audioTracksTimer; |
454 RefPtrWillBeMember<TimeRanges> m_playedTimeRanges; | 469 RefPtrWillBeMember<TimeRanges> m_playedTimeRanges; |
455 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; | 470 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; |
456 | 471 |
457 double m_playbackRate; | 472 double m_playbackRate; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 }; | 625 }; |
611 | 626 |
612 AudioSourceProviderImpl m_audioSourceProvider; | 627 AudioSourceProviderImpl m_audioSourceProvider; |
613 #endif | 628 #endif |
614 | 629 |
615 friend class MediaController; | 630 friend class MediaController; |
616 PersistentWillBeMember<MediaController> m_mediaController; | 631 PersistentWillBeMember<MediaController> m_mediaController; |
617 | 632 |
618 friend class Internals; | 633 friend class Internals; |
619 friend class TrackDisplayUpdateScope; | 634 friend class TrackDisplayUpdateScope; |
635 friend class AutoplayExperimentHelper; | |
636 | |
637 AutoplayExperimentHelper m_autoplayHelper; | |
620 | 638 |
621 static URLRegistry* s_mediaStreamRegistry; | 639 static URLRegistry* s_mediaStreamRegistry; |
622 }; | 640 }; |
623 | 641 |
624 inline bool isHTMLMediaElement(const HTMLElement& element) | 642 inline bool isHTMLMediaElement(const HTMLElement& element) |
625 { | 643 { |
626 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 644 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
627 } | 645 } |
628 | 646 |
629 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 647 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
630 | 648 |
631 } // namespace blink | 649 } // namespace blink |
632 | 650 |
633 #endif // HTMLMediaElement_h | 651 #endif // HTMLMediaElement_h |
OLD | NEW |