Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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(); | |
|
acolwell GONE FROM CHROMIUM
2014/03/20 00:16:35
I have concerns that this doesn't appear to be cal
philipj_slow
2014/03/20 03:01:42
This is the code in question:
if (m_pausedInterna
| |
| 279 } | |
| 280 } | |
| 281 | |
| 282 void MediaControls::endScrubbing() | |
| 283 { | |
| 284 if (m_isPausedForScrubbing) { | |
| 285 m_isPausedForScrubbing = false; | |
| 286 mediaControllerInterface().play(); | |
|
acolwell GONE FROM CHROMIUM
2014/03/21 22:55:47
Should we put a mediaControllerInterface().paused(
philipj_slow
2014/03/23 17:43:41
Done.
| |
| 287 } | |
| 288 } | |
| 289 | |
| 267 void MediaControls::updateCurrentTimeDisplay() | 290 void MediaControls::updateCurrentTimeDisplay() |
| 268 { | 291 { |
| 269 double now = mediaControllerInterface().currentTime(); | 292 double now = mediaControllerInterface().currentTime(); |
| 270 double duration = mediaControllerInterface().duration(); | 293 double duration = mediaControllerInterface().duration(); |
| 271 | 294 |
| 272 // After seek, hide duration display and show current time. | 295 // After seek, hide duration display and show current time. |
| 273 if (now > 0) { | 296 if (now > 0) { |
| 274 m_currentTimeDisplay->show(); | 297 m_currentTimeDisplay->show(); |
| 275 m_durationDisplay->hide(); | 298 m_durationDisplay->hide(); |
| 276 } | 299 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 462 |
| 440 void MediaControls::updateTextTrackDisplay() | 463 void MediaControls::updateTextTrackDisplay() |
| 441 { | 464 { |
| 442 if (!m_textDisplayContainer) | 465 if (!m_textDisplayContainer) |
| 443 createTextTrackDisplay(); | 466 createTextTrackDisplay(); |
| 444 | 467 |
| 445 m_textDisplayContainer->updateDisplay(); | 468 m_textDisplayContainer->updateDisplay(); |
| 446 } | 469 } |
| 447 | 470 |
| 448 } | 471 } |
| OLD | NEW |