| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return false; | 156 return false; |
| 157 | 157 |
| 158 m_enclosure = enclosure.get(); | 158 m_enclosure = enclosure.get(); |
| 159 appendChild(enclosure.release(), exceptionState); | 159 appendChild(enclosure.release(), exceptionState); |
| 160 if (exceptionState.hadException()) | 160 if (exceptionState.hadException()) |
| 161 return false; | 161 return false; |
| 162 | 162 |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 MediaControllerInterface& MediaControls::mediaControllerInterface() const | |
| 167 { | |
| 168 if (m_mediaElement.controller()) | |
| 169 return *m_mediaElement.controller(); | |
| 170 return m_mediaElement; | |
| 171 } | |
| 172 | |
| 173 void MediaControls::reset() | 166 void MediaControls::reset() |
| 174 { | 167 { |
| 175 double duration = mediaControllerInterface().duration(); | 168 double duration = mediaElement().duration(); |
| 176 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime
(duration), ASSERT_NO_EXCEPTION); | 169 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime
(duration), ASSERT_NO_EXCEPTION); |
| 177 m_durationDisplay->setCurrentValue(duration); | 170 m_durationDisplay->setCurrentValue(duration); |
| 178 | 171 |
| 179 updatePlayState(); | 172 updatePlayState(); |
| 180 | 173 |
| 181 updateCurrentTimeDisplay(); | 174 updateCurrentTimeDisplay(); |
| 182 | 175 |
| 183 m_timeline->setDuration(mediaControllerInterface().duration()); | 176 m_timeline->setDuration(duration); |
| 184 m_timeline->setPosition(mediaControllerInterface().currentTime()); | 177 m_timeline->setPosition(mediaElement().currentTime()); |
| 185 | 178 |
| 186 if (!mediaElement().hasAudio()) | 179 if (!mediaElement().hasAudio()) |
| 187 m_volumeSlider->hide(); | 180 m_volumeSlider->hide(); |
| 188 else | 181 else |
| 189 m_volumeSlider->show(); | 182 m_volumeSlider->show(); |
| 190 updateVolume(); | 183 updateVolume(); |
| 191 | 184 |
| 192 refreshClosedCaptionsButtonVisibility(); | 185 refreshClosedCaptionsButtonVisibility(); |
| 193 | 186 |
| 194 if (mediaElement().hasVideo()) | 187 if (mediaElement().hasVideo()) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 { | 219 { |
| 227 return alwaysHideFullscreenControls || !m_panel->hovered(); | 220 return alwaysHideFullscreenControls || !m_panel->hovered(); |
| 228 } | 221 } |
| 229 | 222 |
| 230 void MediaControls::playbackStarted() | 223 void MediaControls::playbackStarted() |
| 231 { | 224 { |
| 232 m_currentTimeDisplay->show(); | 225 m_currentTimeDisplay->show(); |
| 233 m_durationDisplay->hide(); | 226 m_durationDisplay->hide(); |
| 234 | 227 |
| 235 updatePlayState(); | 228 updatePlayState(); |
| 236 m_timeline->setPosition(mediaControllerInterface().currentTime()); | 229 m_timeline->setPosition(mediaElement().currentTime()); |
| 237 updateCurrentTimeDisplay(); | 230 updateCurrentTimeDisplay(); |
| 238 | 231 |
| 239 if (m_isFullscreen) | 232 if (m_isFullscreen) |
| 240 startHideFullscreenControlsTimer(); | 233 startHideFullscreenControlsTimer(); |
| 241 } | 234 } |
| 242 | 235 |
| 243 void MediaControls::playbackProgressed() | 236 void MediaControls::playbackProgressed() |
| 244 { | 237 { |
| 245 m_timeline->setPosition(mediaControllerInterface().currentTime()); | 238 m_timeline->setPosition(mediaElement().currentTime()); |
| 246 updateCurrentTimeDisplay(); | 239 updateCurrentTimeDisplay(); |
| 247 | 240 |
| 248 if (!m_isMouseOverControls && mediaElement().hasVideo()) | 241 if (!m_isMouseOverControls && mediaElement().hasVideo()) |
| 249 makeTransparent(); | 242 makeTransparent(); |
| 250 } | 243 } |
| 251 | 244 |
| 252 void MediaControls::playbackStopped() | 245 void MediaControls::playbackStopped() |
| 253 { | 246 { |
| 254 updatePlayState(); | 247 updatePlayState(); |
| 255 m_timeline->setPosition(mediaControllerInterface().currentTime()); | 248 m_timeline->setPosition(mediaElement().currentTime()); |
| 256 updateCurrentTimeDisplay(); | 249 updateCurrentTimeDisplay(); |
| 257 makeOpaque(); | 250 makeOpaque(); |
| 258 | 251 |
| 259 stopHideFullscreenControlsTimer(); | 252 stopHideFullscreenControlsTimer(); |
| 260 } | 253 } |
| 261 | 254 |
| 262 void MediaControls::updatePlayState() | 255 void MediaControls::updatePlayState() |
| 263 { | 256 { |
| 264 if (m_isPausedForScrubbing) | 257 if (m_isPausedForScrubbing) |
| 265 return; | 258 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 281 { | 274 { |
| 282 if (m_isPausedForScrubbing) { | 275 if (m_isPausedForScrubbing) { |
| 283 m_isPausedForScrubbing = false; | 276 m_isPausedForScrubbing = false; |
| 284 if (mediaElement().togglePlayStateWillPlay()) | 277 if (mediaElement().togglePlayStateWillPlay()) |
| 285 mediaElement().togglePlayState(); | 278 mediaElement().togglePlayState(); |
| 286 } | 279 } |
| 287 } | 280 } |
| 288 | 281 |
| 289 void MediaControls::updateCurrentTimeDisplay() | 282 void MediaControls::updateCurrentTimeDisplay() |
| 290 { | 283 { |
| 291 double now = mediaControllerInterface().currentTime(); | 284 double now = mediaElement().currentTime(); |
| 292 double duration = mediaControllerInterface().duration(); | 285 double duration = mediaElement().duration(); |
| 293 | 286 |
| 294 // After seek, hide duration display and show current time. | 287 // After seek, hide duration display and show current time. |
| 295 if (now > 0) { | 288 if (now > 0) { |
| 296 m_currentTimeDisplay->show(); | 289 m_currentTimeDisplay->show(); |
| 297 m_durationDisplay->hide(); | 290 m_durationDisplay->hide(); |
| 298 } | 291 } |
| 299 | 292 |
| 300 // Allow the theme to format the time. | 293 // Allow the theme to format the time. |
| 301 m_currentTimeDisplay->setInnerText(RenderTheme::theme().formatMediaControlsC
urrentTime(now, duration), IGNORE_EXCEPTION); | 294 m_currentTimeDisplay->setInnerText(RenderTheme::theme().formatMediaControlsC
urrentTime(now, duration), IGNORE_EXCEPTION); |
| 302 m_currentTimeDisplay->setCurrentValue(now); | 295 m_currentTimeDisplay->setCurrentValue(now); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 449 |
| 457 void MediaControls::updateTextTrackDisplay() | 450 void MediaControls::updateTextTrackDisplay() |
| 458 { | 451 { |
| 459 if (!m_textDisplayContainer) | 452 if (!m_textDisplayContainer) |
| 460 createTextTrackDisplay(); | 453 createTextTrackDisplay(); |
| 461 | 454 |
| 462 m_textDisplayContainer->updateDisplay(); | 455 m_textDisplayContainer->updateDisplay(); |
| 463 } | 456 } |
| 464 | 457 |
| 465 } | 458 } |
| OLD | NEW |