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

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

Issue 204803002: Make scrubbing a MediaControls-internal concept (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: check mediaControllerInterface().paused() Created 6 years, 9 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
« no previous file with comments | « Source/core/html/shadow/MediaControls.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 , m_timeline(0) 58 , m_timeline(0)
59 , m_muteButton(0) 59 , m_muteButton(0)
60 , m_volumeSlider(0) 60 , m_volumeSlider(0)
61 , m_toggleClosedCaptionsButton(0) 61 , m_toggleClosedCaptionsButton(0)
62 , m_fullScreenButton(0) 62 , m_fullScreenButton(0)
63 , m_durationDisplay(0) 63 , m_durationDisplay(0)
64 , m_enclosure(0) 64 , m_enclosure(0)
65 , m_hideFullscreenControlsTimer(this, &MediaControls::hideFullscreenControls TimerFired) 65 , m_hideFullscreenControlsTimer(this, &MediaControls::hideFullscreenControls TimerFired)
66 , m_isFullscreen(false) 66 , m_isFullscreen(false)
67 , m_isMouseOverControls(false) 67 , m_isMouseOverControls(false)
68 , m_isPausedForScrubbing(false)
68 { 69 {
69 } 70 }
70 71
71 PassRefPtr<MediaControls> MediaControls::create(HTMLMediaElement& mediaElement) 72 PassRefPtr<MediaControls> MediaControls::create(HTMLMediaElement& mediaElement)
72 { 73 {
73 RefPtr<MediaControls> controls = adoptRef(new MediaControls(mediaElement)); 74 RefPtr<MediaControls> controls = adoptRef(new MediaControls(mediaElement));
74 75
75 if (controls->initializeControls()) 76 if (controls->initializeControls())
76 return controls.release(); 77 return controls.release();
77 78
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return *m_mediaElement.controller(); 170 return *m_mediaElement.controller();
170 return m_mediaElement; 171 return m_mediaElement;
171 } 172 }
172 173
173 void MediaControls::reset() 174 void MediaControls::reset()
174 { 175 {
175 double duration = mediaControllerInterface().duration(); 176 double duration = mediaControllerInterface().duration();
176 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION); 177 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime (duration), ASSERT_NO_EXCEPTION);
177 m_durationDisplay->setCurrentValue(duration); 178 m_durationDisplay->setCurrentValue(duration);
178 179
179 m_playButton->updateDisplayType(); 180 updatePlayState();
180 181
181 updateCurrentTimeDisplay(); 182 updateCurrentTimeDisplay();
182 183
183 m_timeline->setDuration(mediaControllerInterface().duration()); 184 m_timeline->setDuration(mediaControllerInterface().duration());
184 m_timeline->setPosition(mediaControllerInterface().currentTime()); 185 m_timeline->setPosition(mediaControllerInterface().currentTime());
185 186
186 if (!mediaControllerInterface().hasAudio()) { 187 if (!mediaControllerInterface().hasAudio()) {
187 m_volumeSlider->hide(); 188 m_volumeSlider->hide();
188 } else { 189 } else {
189 m_volumeSlider->show(); 190 m_volumeSlider->show();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 bool MediaControls::shouldHideFullscreenControls() 227 bool MediaControls::shouldHideFullscreenControls()
227 { 228 {
228 return alwaysHideFullscreenControls || !m_panel->hovered(); 229 return alwaysHideFullscreenControls || !m_panel->hovered();
229 } 230 }
230 231
231 void MediaControls::playbackStarted() 232 void MediaControls::playbackStarted()
232 { 233 {
233 m_currentTimeDisplay->show(); 234 m_currentTimeDisplay->show();
234 m_durationDisplay->hide(); 235 m_durationDisplay->hide();
235 236
236 if (m_overlayPlayButton) 237 updatePlayState();
237 m_overlayPlayButton->updateDisplayType();
238 m_playButton->updateDisplayType();
239 m_timeline->setPosition(mediaControllerInterface().currentTime()); 238 m_timeline->setPosition(mediaControllerInterface().currentTime());
240 updateCurrentTimeDisplay(); 239 updateCurrentTimeDisplay();
241 240
242 if (m_isFullscreen) 241 if (m_isFullscreen)
243 startHideFullscreenControlsTimer(); 242 startHideFullscreenControlsTimer();
244 } 243 }
245 244
246 void MediaControls::playbackProgressed() 245 void MediaControls::playbackProgressed()
247 { 246 {
248 m_timeline->setPosition(mediaControllerInterface().currentTime()); 247 m_timeline->setPosition(mediaControllerInterface().currentTime());
249 updateCurrentTimeDisplay(); 248 updateCurrentTimeDisplay();
250 249
251 if (!m_isMouseOverControls && mediaElement().hasVideo()) 250 if (!m_isMouseOverControls && mediaElement().hasVideo())
252 makeTransparent(); 251 makeTransparent();
253 } 252 }
254 253
255 void MediaControls::playbackStopped() 254 void MediaControls::playbackStopped()
256 { 255 {
257 if (m_overlayPlayButton) 256 updatePlayState();
258 m_overlayPlayButton->updateDisplayType();
259 m_playButton->updateDisplayType();
260 m_timeline->setPosition(mediaControllerInterface().currentTime()); 257 m_timeline->setPosition(mediaControllerInterface().currentTime());
261 updateCurrentTimeDisplay(); 258 updateCurrentTimeDisplay();
262 makeOpaque(); 259 makeOpaque();
263 260
264 stopHideFullscreenControlsTimer(); 261 stopHideFullscreenControlsTimer();
265 } 262 }
266 263
264 void MediaControls::updatePlayState()
265 {
266 if (m_isPausedForScrubbing)
267 return;
268
269 if (m_overlayPlayButton)
270 m_overlayPlayButton->updateDisplayType();
271 m_playButton->updateDisplayType();
272 }
273
274 void MediaControls::beginScrubbing()
275 {
276 if (!mediaControllerInterface().paused()) {
277 m_isPausedForScrubbing = true;
278 mediaControllerInterface().pause();
279 }
280 }
281
282 void MediaControls::endScrubbing()
283 {
284 if (m_isPausedForScrubbing) {
285 m_isPausedForScrubbing = false;
286 if (mediaControllerInterface().paused())
287 mediaControllerInterface().play();
288 }
289 }
290
267 void MediaControls::updateCurrentTimeDisplay() 291 void MediaControls::updateCurrentTimeDisplay()
268 { 292 {
269 double now = mediaControllerInterface().currentTime(); 293 double now = mediaControllerInterface().currentTime();
270 double duration = mediaControllerInterface().duration(); 294 double duration = mediaControllerInterface().duration();
271 295
272 // After seek, hide duration display and show current time. 296 // After seek, hide duration display and show current time.
273 if (now > 0) { 297 if (now > 0) {
274 m_currentTimeDisplay->show(); 298 m_currentTimeDisplay->show();
275 m_durationDisplay->hide(); 299 m_durationDisplay->hide();
276 } 300 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 463
440 void MediaControls::updateTextTrackDisplay() 464 void MediaControls::updateTextTrackDisplay()
441 { 465 {
442 if (!m_textDisplayContainer) 466 if (!m_textDisplayContainer)
443 createTextTrackDisplay(); 467 createTextTrackDisplay();
444 468
445 m_textDisplayContainer->updateDisplay(); 469 m_textDisplayContainer->updateDisplay();
446 } 470 }
447 471
448 } 472 }
OLDNEW
« no previous file with comments | « Source/core/html/shadow/MediaControls.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698