| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 void MediaControls::setMediaController(MediaControllerInterface* controller) | 148 void MediaControls::setMediaController(MediaControllerInterface* controller) |
| 149 { | 149 { |
| 150 if (m_mediaController == controller) | 150 if (m_mediaController == controller) |
| 151 return; | 151 return; |
| 152 m_mediaController = controller; | 152 m_mediaController = controller; |
| 153 | 153 |
| 154 if (m_panel) | 154 m_panel->setMediaController(controller); |
| 155 m_panel->setMediaController(controller); | |
| 156 if (m_textDisplayContainer) | 155 if (m_textDisplayContainer) |
| 157 m_textDisplayContainer->setMediaController(controller); | 156 m_textDisplayContainer->setMediaController(controller); |
| 158 if (m_playButton) | 157 m_playButton->setMediaController(controller); |
| 159 m_playButton->setMediaController(controller); | 158 m_currentTimeDisplay->setMediaController(controller); |
| 160 if (m_currentTimeDisplay) | 159 m_timeline->setMediaController(controller); |
| 161 m_currentTimeDisplay->setMediaController(controller); | 160 m_panelMuteButton->setMediaController(controller); |
| 162 if (m_timeline) | 161 m_volumeSlider->setMediaController(controller); |
| 163 m_timeline->setMediaController(controller); | 162 m_toggleClosedCaptionsButton->setMediaController(controller); |
| 164 if (m_panelMuteButton) | 163 m_fullScreenButton->setMediaController(controller); |
| 165 m_panelMuteButton->setMediaController(controller); | 164 m_durationDisplay->setMediaController(controller); |
| 166 if (m_volumeSlider) | 165 m_enclosure->setMediaController(controller); |
| 167 m_volumeSlider->setMediaController(controller); | |
| 168 if (m_toggleClosedCaptionsButton) | |
| 169 m_toggleClosedCaptionsButton->setMediaController(controller); | |
| 170 if (m_fullScreenButton) | |
| 171 m_fullScreenButton->setMediaController(controller); | |
| 172 if (m_durationDisplay) | |
| 173 m_durationDisplay->setMediaController(controller); | |
| 174 if (m_enclosure) | |
| 175 m_enclosure->setMediaController(controller); | |
| 176 } | 166 } |
| 177 | 167 |
| 178 void MediaControls::reset() | 168 void MediaControls::reset() |
| 179 { | 169 { |
| 180 Page* page = document().page(); | 170 Page* page = document().page(); |
| 181 if (!page) | 171 if (!page) |
| 182 return; | 172 return; |
| 183 | 173 |
| 184 double duration = m_mediaController->duration(); | 174 double duration = m_mediaController->duration(); |
| 185 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime
(duration), ASSERT_NO_EXCEPTION); | 175 m_durationDisplay->setInnerText(RenderTheme::theme().formatMediaControlsTime
(duration), ASSERT_NO_EXCEPTION); |
| 186 m_durationDisplay->setCurrentValue(duration); | 176 m_durationDisplay->setCurrentValue(duration); |
| 187 | 177 |
| 188 m_playButton->updateDisplayType(); | 178 m_playButton->updateDisplayType(); |
| 189 | 179 |
| 190 updateCurrentTimeDisplay(); | 180 updateCurrentTimeDisplay(); |
| 191 | 181 |
| 192 m_timeline->setDuration(m_mediaController->duration()); | 182 m_timeline->setDuration(m_mediaController->duration()); |
| 193 m_timeline->setPosition(m_mediaController->currentTime()); | 183 m_timeline->setPosition(m_mediaController->currentTime()); |
| 194 | 184 |
| 195 m_panelMuteButton->show(); | 185 m_panelMuteButton->show(); |
| 196 | 186 |
| 197 if (m_volumeSlider) { | 187 if (!m_mediaController->hasAudio()) { |
| 198 if (!m_mediaController->hasAudio()) | 188 m_volumeSlider->hide(); |
| 199 m_volumeSlider->hide(); | 189 } else { |
| 200 else { | 190 m_volumeSlider->show(); |
| 201 m_volumeSlider->show(); | 191 m_volumeSlider->setVolume(m_mediaController->volume()); |
| 202 m_volumeSlider->setVolume(m_mediaController->volume()); | |
| 203 } | |
| 204 } | 192 } |
| 205 | 193 |
| 206 refreshClosedCaptionsButtonVisibility(); | 194 refreshClosedCaptionsButtonVisibility(); |
| 207 | 195 |
| 208 if (m_fullScreenButton) { | 196 if (m_mediaController->hasVideo()) |
| 209 if (m_mediaController->hasVideo()) | 197 m_fullScreenButton->show(); |
| 210 m_fullScreenButton->show(); | 198 else |
| 211 else | 199 m_fullScreenButton->hide(); |
| 212 m_fullScreenButton->hide(); | |
| 213 } | |
| 214 | 200 |
| 215 makeOpaque(); | 201 makeOpaque(); |
| 216 } | 202 } |
| 217 | 203 |
| 218 void MediaControls::show() | 204 void MediaControls::show() |
| 219 { | 205 { |
| 220 makeOpaque(); | 206 makeOpaque(); |
| 221 m_panel->setIsDisplayed(true); | 207 m_panel->setIsDisplayed(true); |
| 222 m_panel->show(); | 208 m_panel->show(); |
| 223 } | 209 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 m_panelMuteButton->changedMute(); | 302 m_panelMuteButton->changedMute(); |
| 317 | 303 |
| 318 if (m_mediaController->muted()) | 304 if (m_mediaController->muted()) |
| 319 m_volumeSlider->setVolume(0); | 305 m_volumeSlider->setVolume(0); |
| 320 else | 306 else |
| 321 m_volumeSlider->setVolume(m_mediaController->volume()); | 307 m_volumeSlider->setVolume(m_mediaController->volume()); |
| 322 } | 308 } |
| 323 | 309 |
| 324 void MediaControls::changedVolume() | 310 void MediaControls::changedVolume() |
| 325 { | 311 { |
| 326 if (m_volumeSlider) | 312 m_volumeSlider->setVolume(m_mediaController->volume()); |
| 327 m_volumeSlider->setVolume(m_mediaController->volume()); | 313 if (m_panelMuteButton->renderer()) |
| 328 if (m_panelMuteButton && m_panelMuteButton->renderer()) | |
| 329 m_panelMuteButton->renderer()->repaint(); | 314 m_panelMuteButton->renderer()->repaint(); |
| 330 } | 315 } |
| 331 | 316 |
| 332 void MediaControls::changedClosedCaptionsVisibility() | 317 void MediaControls::changedClosedCaptionsVisibility() |
| 333 { | 318 { |
| 334 if (m_toggleClosedCaptionsButton) | 319 m_toggleClosedCaptionsButton->updateDisplayType(); |
| 335 m_toggleClosedCaptionsButton->updateDisplayType(); | |
| 336 } | 320 } |
| 337 | 321 |
| 338 void MediaControls::refreshClosedCaptionsButtonVisibility() | 322 void MediaControls::refreshClosedCaptionsButtonVisibility() |
| 339 { | 323 { |
| 340 if (!m_toggleClosedCaptionsButton) | |
| 341 return; | |
| 342 | |
| 343 if (m_mediaController->hasClosedCaptions()) | 324 if (m_mediaController->hasClosedCaptions()) |
| 344 m_toggleClosedCaptionsButton->show(); | 325 m_toggleClosedCaptionsButton->show(); |
| 345 else | 326 else |
| 346 m_toggleClosedCaptionsButton->hide(); | 327 m_toggleClosedCaptionsButton->hide(); |
| 347 } | 328 } |
| 348 | 329 |
| 349 void MediaControls::closedCaptionTracksChanged() | 330 void MediaControls::closedCaptionTracksChanged() |
| 350 { | 331 { |
| 351 refreshClosedCaptionsButtonVisibility(); | 332 refreshClosedCaptionsButtonVisibility(); |
| 352 } | 333 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 } | 430 } |
| 450 | 431 |
| 451 void MediaControls::createTextTrackDisplay() | 432 void MediaControls::createTextTrackDisplay() |
| 452 { | 433 { |
| 453 if (m_textDisplayContainer) | 434 if (m_textDisplayContainer) |
| 454 return; | 435 return; |
| 455 | 436 |
| 456 RefPtr<MediaControlTextTrackContainerElement> textDisplayContainer = MediaCo
ntrolTextTrackContainerElement::create(document()); | 437 RefPtr<MediaControlTextTrackContainerElement> textDisplayContainer = MediaCo
ntrolTextTrackContainerElement::create(document()); |
| 457 m_textDisplayContainer = textDisplayContainer.get(); | 438 m_textDisplayContainer = textDisplayContainer.get(); |
| 458 | 439 |
| 459 if (m_mediaController) | 440 m_textDisplayContainer->setMediaController(m_mediaController); |
| 460 m_textDisplayContainer->setMediaController(m_mediaController); | |
| 461 | 441 |
| 462 insertTextTrackContainer(textDisplayContainer.release()); | 442 insertTextTrackContainer(textDisplayContainer.release()); |
| 463 } | 443 } |
| 464 | 444 |
| 465 void MediaControls::showTextTrackDisplay() | 445 void MediaControls::showTextTrackDisplay() |
| 466 { | 446 { |
| 467 if (!m_textDisplayContainer) | 447 if (!m_textDisplayContainer) |
| 468 createTextTrackDisplay(); | 448 createTextTrackDisplay(); |
| 469 m_textDisplayContainer->show(); | 449 m_textDisplayContainer->show(); |
| 470 } | 450 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 484 m_textDisplayContainer->updateDisplay(); | 464 m_textDisplayContainer->updateDisplay(); |
| 485 } | 465 } |
| 486 | 466 |
| 487 void MediaControls::insertTextTrackContainer(PassRefPtr<MediaControlTextTrackCon
tainerElement> textTrackContainer) | 467 void MediaControls::insertTextTrackContainer(PassRefPtr<MediaControlTextTrackCon
tainerElement> textTrackContainer) |
| 488 { | 468 { |
| 489 // Insert it before the first controller element so it always displays behin
d the controls. | 469 // Insert it before the first controller element so it always displays behin
d the controls. |
| 490 insertBefore(textTrackContainer, m_enclosure); | 470 insertBefore(textTrackContainer, m_enclosure); |
| 491 } | 471 } |
| 492 | 472 |
| 493 } | 473 } |
| OLD | NEW |