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/events/MouseEvent.h"
31 #include "core/html/HTMLDivElement.h"
32 #include "core/html/shadow/MediaControlElements.h"
33 #include "core/rendering/RenderTheme.h"
44 class MediaControls : public HTMLDivElement {
46 virtual ~MediaControls() {}
48 static PassRefPtr<MediaControls> create(Document&);
50 virtual void setMediaController(MediaControllerInterface*);
57 void bufferingProgressed();
58 virtual void playbackStarted();
59 void playbackProgressed();
60 virtual void playbackStopped();
62 void updateCurrentTimeDisplay();
63 void showVolumeSlider();
68 void changedClosedCaptionsVisibility();
69 void refreshClosedCaptionsButtonVisibility();
70 void closedCaptionTracksChanged();
72 void enteredFullscreen();
73 void exitedFullscreen();
75 void updateTextTrackDisplay();
78 explicit MediaControls(Document&);
80 virtual bool initializeControls(Document&);
82 virtual bool shouldHideControls();
84 virtual void insertTextTrackContainer(PassRefPtr<MediaControlTextTrackContainerElement>);
88 void makeTransparent();
90 void hideFullscreenControlsTimerFired(Timer<MediaControls>*);
91 void startHideFullscreenControlsTimer();
92 void stopHideFullscreenControlsTimer();
94 void createTextTrackDisplay();
95 void showTextTrackDisplay();
96 void hideTextTrackDisplay();
99 virtual bool isMediaControls() const OVERRIDE FINAL { return true; }
100 virtual bool willRespondToMouseMoveEvents() OVERRIDE { return true; }
101 virtual void defaultEventHandler(Event*) OVERRIDE;
102 bool containsRelatedTarget(Event*);
105 virtual const AtomicString& shadowPseudoId() const OVERRIDE;
107 MediaControllerInterface* m_mediaController;
109 // Container for the media control elements.
110 MediaControlPanelElement* m_panel;
112 // Container for the text track cues.
113 MediaControlTextTrackContainerElement* m_textDisplayContainer;
115 // Media control elements.
116 MediaControlPlayButtonElement* m_playButton;
117 MediaControlCurrentTimeDisplayElement* m_currentTimeDisplay;
118 MediaControlTimelineElement* m_timeline;
119 MediaControlPanelMuteButtonElement* m_panelMuteButton;
120 MediaControlPanelVolumeSliderElement* m_volumeSlider;
121 MediaControlToggleClosedCaptionsButtonElement* m_toggleClosedCaptionsButton;
122 MediaControlFullscreenButtonElement* m_fullScreenButton;
123 MediaControlTimeRemainingDisplayElement* m_durationDisplay;
124 MediaControlPanelEnclosureElement* m_enclosure;
126 Timer<MediaControls> m_hideFullscreenControlsTimer;
128 bool m_isMouseOverControls;
131 DEFINE_NODE_TYPE_CASTS(MediaControls, isMediaControls());