Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: Source/core/html/shadow/MediaControls.js

Issue 456323002: [WIP] Re-implement MediaControls in Blink-in-JS (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 installClass('MediaControls', function(global, MediaControlsPrototype) {
8
9 var kFadeInDuration = 0.1;
10 var kFadeOutDuration = 0.3;
11
12 function show(element) {
13 element.style.removeProperty('display');
14 }
15
16 function hide(element) {
17 element.style.setProperty('display', 'none')
18 }
19
20 function createElement(parent, pseudoId) {
21 var e = global.document.createElement(parent);
22 if (!e) {
23 return null;
24 }
25 e.setAttribute('pseudo', pseudoId);
26 return e;
27 }
28
29 function createPanel() {
30 var panel = createElement('div', '-webkit-media-controls-panel')
31 panel.isDisplayed_ = false;
32 panel.opaque_ = true;
33 panel.transitionTimer_ = null;
34 panel.startTimer = function() {
35 stopTimer();
36 this.transitionTimer_ = setTimeout(kFadeOutDuration, this.transition TimerFired);
abarth-chromium 2014/08/11 18:04:12 Why not listen for the transition end event?
hajimehoshi 2014/08/12 06:54:09 I'm just copying implementation from C++. Now I st
37 };
38 panel.stopTimer = function() {
39 if (this.transitionTimer_ !== null) {
40 clearTimeout(this.this.transitionTimer_);
41 this.transitionTimer_ = null;
42 }
43 };
44 panel.transitionTimerFired = function() {
45 if (!this.opaque_) {
46 hide();
47 }
48 this.stopTimer();
49 };
abarth-chromium 2014/08/11 18:04:12 Should we use a web animation instead of a CSS tra
hajimehoshi 2014/08/12 06:54:09 Same as above.
50 panel.makeOpaque = function() {
51 if (this.opaque_) {
52 return;
53 }
54 this.style.transformProperty = 'opacity';
55 this.style.transformDuration = kFadeInDuration + 's';
56 this.style.opacity = 1.0;
57 this.opaque_ = true;
58 if (this.isDisplayed_) {
59 show(this);
60 }
61 };
62 panel.makeTransparent = function() {
63 if (!this.opaque_) {
64 return;
65 }
66 this.style.transformProperty = 'opacity';
67 this.style.transformDuration = kFadeOutDuration + 's';
68 this.style.opacity = 0.0;
69 this.opacity_ = false;
70 this.startTimer();
71 };
72 panel.setIsDisplayed = function(isDisplayed) {
73 this.isDisplayed = isDisplayed;
74 };
75 return panel;
76 }
77
78 function createTimeline() {
79 var timeline = createElement('input', '-webkit-media-controls-timeline') ;
80 timeline.setAttribute('type', 'range');
81 timeline.setAttribute('step', 'any');
82 timeline.defaultEventHandler = function(event) {
83 // TODO
84 };
85 timeline.willRespondToMouseClickEvents = function() {
86 // TODO
87 };
88 timeline.setPosition = function(currentTime) {
89 this.value = currentTime;
90 };
91 timeline.setDuration = function(duration) {
92 this.setAttribute('max', isFinite(duration) ? duration : 0);
93 };
94 return timeline;
95 }
96
97 MediaControlsPrototype.createdCallback = function(mediaElement) {
98 this.mediaElement_ = mediaElement;
99
100 this.setAttribute('pseudo', '-webkit-media-controls');
101
102 // TODO: Maybe OverlayEnclosure is needed
103
104 var enclosure = createElement('div', '-webkit-media-controls-enclosure') ;
105 this.panel_ = createPanel();
106
107 var playButton = createElement('input', '-webkit-media-controls-play-but ton');
108 this.panel_.appendChild(playButton);
109 this.timeline_ = createTimeline();
110 this.panel_.appendChild(this.timeline_);
111 var currentTimeDisplay = createElement('div', '-webkit-media-controls-cu rrent-time-display');
112 this.panel_.appendChild(currentTimeDisplay);
113 this.durationDisplay_ = createElement('div', '-webkit-media-controls-tim e-remaining-display');
114 this.panel_.appendChild(this.durationDisplay_);
115 var muteButton = createElement('input', '-webkit-media-controls-mute-but ton');
116 this.panel_.appendChild(muteButton);
117 this.volumeSlider_ = createElement('input', '-webkit-media-controls-volu me-slider');
118 this.panel_.appendChild(this.volumeSlider_);
119 this.fullscreenButton_ = createElement('input', '-webkit-media-controls- fullscreen-button');
120 this.panel_.appendChild(this.fullscreenButton_);
121
122 enclosure.appendChild(this.panel_);
123 this.appendChild(enclosure);
124 };
125
126 MediaControlsPrototype.reset = function() {
127 var duration = this.mediaElement_.duration;
128 this.durationDisplay_.innerText = "foo"; // TODO
129 //this.durationDisplay_.setCurrentValue(duration);
130 this.updatePlayState();
131 this.updateCurrentTimeDisplay();
132 this.timeline_.setDuration(duration);
133 this.timeline_.setPosition(this.mediaElement_.currentTime);
134 if (this.mediaElement_.hasAudio()) {
135 hide(this.volumeSlider_);
136 } else {
137 show(this.volumeSlider_);
138 }
139 this.updateVolume();
140 this.refreshClosedCaptionsButtonVisibility();
141 if (this.mediaElement_.hasVideo() && this.fullscreenIsSupported()) {
142 show(this.fullscreenButton_);
143 } else {
144 hide(this.fullscreenButton_);
145 }
146 };
147
148 MediaControlsPrototype.show = function() {
149 // TODO
haraken 2014/08/11 11:09:33 Nit: Blink uses FIXME instead of TODO.
150 };
151
152 MediaControlsPrototype.mediaElementFocused = function() {
153 // TODO
154 };
155
156 MediaControlsPrototype.hide = function() {
157 // TODO
158 };
159
160 MediaControlsPrototype.makeOpaque = function() {
161 this.panel_.makeOpaque();
162 };
163
164 MediaControlsPrototype.makeTransparent = function() {
165 this.panel_.makeTransparent();
166 };
167
168 MediaControlsPrototype.shouldHideMediaControls = function(behaviorFlags) {
169 // TODO
170 };
171
172 MediaControlsPrototype.playbackStarted = function() {
173 // TODO
174 };
175
176 MediaControlsPrototype.updatePlayState = function() {
177 // TODO
178 };
179
180 MediaControlsPrototype.beginScrubbing = function() {
181 // TODO
182 };
183
184 MediaControlsPrototype.endScrubbing = function() {
185 // TODO
186 };
187
188 MediaControlsPrototype.updateCurrentTimeDisplay = function() {
189 // TODO
190 };
191
192 MediaControlsPrototype.updateVolume = function() {
193 // TODO
194 };
195
196 MediaControlsPrototype.changedClosedCaptionsVisibility = function() {
197 // TODO
198 };
199
200 MediaControlsPrototype.refreshClosedCaptionsButtonVisibility = function() {
201 // TODO
202 };
203
204 MediaControlsPrototype.closedCaptionTracksChanged = function() {
205 // TODO
206 };
207
208 MediaControlsPrototype.enteredFullscreen = function() {
209 // TODO
210 };
211
212 MediaControlsPrototype.exitedFullscreen = function() {
213 // TODO
214 };
215
216 MediaControlsPrototype.defaultEventHandler = function(event) {
217 // TODO
218 };
219
220 MediaControlsPrototype.hideMediaControlsTimerFired = function(timer) {
221 // TODO
222 };
223
224 MediaControlsPrototype.startHideMediaControlsTimer = function() {
225 // TODO
226 };
227
228 MediaControlsPrototype.stopHideMediaControlsTimer = function() {
229 // TODO
230 };
231
232 MediaControlsPrototype.containsRelatedTarget = function(event) {
233 // TODO
234 };
235
236 MediaControlsPrototype.createTextTrackDisplay = function() {
237 // TODO
238 };
239
240 MediaControlsPrototype.showTextTarckDisplay = function() {
241 // TODO
242 };
243
244 MediaControlsPrototype.hideTextTrackDisplay = function() {
245 // TODO
246 };
247
248 MediaControlsPrototype.updateTextTrackDisplay = function() {
249 // TODO
250 };
251 });
OLDNEW
« Source/core/html/HTMLVideoElement.js ('K') | « Source/core/html/shadow/MediaControls.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698