2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef MediaControls_h
28 #define MediaControls_h
30 #include "core/html/HTMLDivElement.h"
31 #include "core/html/shadow/MediaControlElements.h"
38 class MediaControls FINAL : public HTMLDivElement {
40 static PassRefPtrWillBeRawPtr<MediaControls> create(HTMLMediaElement&);
42 HTMLMediaElement& mediaElement() const { return *m_mediaElement; }
49 void playbackStarted();
50 void playbackProgressed();
51 void playbackStopped();
53 void beginScrubbing();
56 void updateCurrentTimeDisplay();
60 void changedClosedCaptionsVisibility();
61 void refreshClosedCaptionsButtonVisibility();
62 void textTracksChanged();
64 void enteredFullscreen();
65 void exitedFullscreen();
67 void startedCasting();
68 void stoppedCasting();
69 void refreshCastButtonVisibility();
70 void showOverlayCastButton();
72 void updateTextTrackDisplay();
74 void mediaElementFocused();
76 virtual void trace(Visitor*) OVERRIDE;
79 explicit MediaControls(HTMLMediaElement&);
81 bool initializeControls();
84 void makeTransparent();
86 void updatePlayState();
88 enum HideBehaviorFlags {
89 IgnoreVideoHover = 1 << 0,
91 IgnoreControlsHover = 1 << 2
94 bool shouldHideMediaControls(unsigned behaviorFlags = 0) const;
95 void hideMediaControlsTimerFired(Timer<MediaControls>*);
96 void startHideMediaControlsTimer();
97 void stopHideMediaControlsTimer();
98 void resetHideMediaControlsTimer();
100 void createTextTrackDisplay();
101 void showTextTrackDisplay();
102 void hideTextTrackDisplay();
105 virtual bool isMediaControls() const OVERRIDE { return true; }
106 virtual bool willRespondToMouseMoveEvents() OVERRIDE { return true; }
107 virtual void defaultEventHandler(Event*) OVERRIDE;
108 bool containsRelatedTarget(Event*);
111 virtual const AtomicString& shadowPseudoId() const OVERRIDE;
113 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement;
115 // Container for the media control elements.
116 RawPtrWillBeMember<MediaControlPanelElement> m_panel;
118 // Container for the text track cues.
119 RawPtrWillBeMember<MediaControlTextTrackContainerElement> m_textDisplayContainer;
121 // Media control elements.
122 RawPtrWillBeMember<MediaControlOverlayPlayButtonElement> m_overlayPlayButton;
123 RawPtrWillBeMember<MediaControlOverlayEnclosureElement> m_overlayEnclosure;
124 RawPtrWillBeMember<MediaControlPlayButtonElement> m_playButton;
125 RawPtrWillBeMember<MediaControlCurrentTimeDisplayElement> m_currentTimeDisplay;
126 RawPtrWillBeMember<MediaControlTimelineElement> m_timeline;
127 RawPtrWillBeMember<MediaControlMuteButtonElement> m_muteButton;
128 RawPtrWillBeMember<MediaControlVolumeSliderElement> m_volumeSlider;
129 RawPtrWillBeMember<MediaControlToggleClosedCaptionsButtonElement> m_toggleClosedCaptionsButton;
130 RawPtrWillBeMember<MediaControlFullscreenButtonElement> m_fullScreenButton;
131 RawPtrWillBeMember<MediaControlCastButtonElement> m_castButton;
132 RawPtrWillBeMember<MediaControlCastButtonElement> m_overlayCastButton;
133 RawPtrWillBeMember<MediaControlTimeRemainingDisplayElement> m_durationDisplay;
134 RawPtrWillBeMember<MediaControlPanelEnclosureElement> m_enclosure;
136 Timer<MediaControls> m_hideMediaControlsTimer;
137 bool m_isMouseOverControls : 1;
138 bool m_isPausedForScrubbing : 1;
139 bool m_wasLastEventTouch : 1;
142 DEFINE_ELEMENT_TYPE_CASTS(MediaControls, isMediaControls());