| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 if (m_position == MediaPlayer::invalidTime()) { | 152 if (m_position == MediaPlayer::invalidTime()) { |
| 153 // Some clocks may return times outside the range of [0..duration]. | 153 // Some clocks may return times outside the range of [0..duration]. |
| 154 m_position = std::max(0.0, std::min(duration(), m_clock->currentTime()))
; | 154 m_position = std::max(0.0, std::min(duration(), m_clock->currentTime()))
; |
| 155 m_clearPositionTimer.startOneShot(0, FROM_HERE); | 155 m_clearPositionTimer.startOneShot(0, FROM_HERE); |
| 156 } | 156 } |
| 157 | 157 |
| 158 return m_position; | 158 return m_position; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState
) | 161 void MediaController::setCurrentTime(double time) |
| 162 { | 162 { |
| 163 // When the user agent is to seek the media controller to a particular new p
layback position, | 163 // When the user agent is to seek the media controller to a particular new p
layback position, |
| 164 // it must follow these steps: | 164 // it must follow these steps: |
| 165 // If the new playback position is less than zero, then set it to zero. | 165 // If the new playback position is less than zero, then set it to zero. |
| 166 time = std::max(0.0, time); | 166 time = std::max(0.0, time); |
| 167 | 167 |
| 168 // If the new playback position is greater than the media controller duratio
n, then set it | 168 // If the new playback position is greater than the media controller duratio
n, then set it |
| 169 // to the media controller duration. | 169 // to the media controller duration. |
| 170 time = std::min(time, duration()); | 170 time = std::min(time, duration()); |
| 171 | 171 |
| 172 // Set the media controller position to the new playback position. | 172 // Set the media controller position to the new playback position. |
| 173 m_position = time; | 173 m_position = time; |
| 174 m_clock->setCurrentTime(time); | 174 m_clock->setCurrentTime(time); |
| 175 | 175 |
| 176 // Seek each slaved media element to the new playback position relative to t
he media element timeline. | 176 // Seek each slaved media element to the new playback position relative to t
he media element timeline. |
| 177 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it !
= m_mediaElements.end(); ++it) | 177 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it !
= m_mediaElements.end(); ++it) |
| 178 (*it)->seek(time, exceptionState); | 178 (*it)->seek(time); |
| 179 | 179 |
| 180 scheduleTimeupdateEvent(); | 180 scheduleTimeupdateEvent(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void MediaController::unpause() | 183 void MediaController::unpause() |
| 184 { | 184 { |
| 185 // When the unpause() method is invoked, if the MediaController is a paused
media controller, | 185 // When the unpause() method is invoked, if the MediaController is a paused
media controller, |
| 186 if (!m_paused) | 186 if (!m_paused) |
| 187 return; | 187 return; |
| 188 | 188 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 477 } |
| 478 | 478 |
| 479 void MediaController::bringElementUpToSpeed(HTMLMediaElement* element) | 479 void MediaController::bringElementUpToSpeed(HTMLMediaElement* element) |
| 480 { | 480 { |
| 481 ASSERT(element); | 481 ASSERT(element); |
| 482 ASSERT(m_mediaElements.contains(element)); | 482 ASSERT(m_mediaElements.contains(element)); |
| 483 | 483 |
| 484 // When the user agent is to bring a media element up to speed with its new
media controller, | 484 // When the user agent is to bring a media element up to speed with its new
media controller, |
| 485 // it must seek that media element to the MediaController's media controller
position relative | 485 // it must seek that media element to the MediaController's media controller
position relative |
| 486 // to the media element's timeline. | 486 // to the media element's timeline. |
| 487 element->seek(currentTime(), IGNORE_EXCEPTION); | 487 element->seek(currentTime()); |
| 488 | 488 |
| 489 // Update volume to take controller volume and mute into account. | 489 // Update volume to take controller volume and mute into account. |
| 490 element->updateVolume(); | 490 element->updateVolume(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 bool MediaController::isRestrained() const | 493 bool MediaController::isRestrained() const |
| 494 { | 494 { |
| 495 ASSERT(!m_mediaElements.isEmpty()); | 495 ASSERT(!m_mediaElements.isEmpty()); |
| 496 | 496 |
| 497 // A MediaController is a restrained media controller if the MediaController
is a playing media | 497 // A MediaController is a restrained media controller if the MediaController
is a playing media |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 { | 618 { |
| 619 #if ENABLE(OILPAN) | 619 #if ENABLE(OILPAN) |
| 620 visitor->trace(m_mediaElements); | 620 visitor->trace(m_mediaElements); |
| 621 visitor->trace(m_pendingEventsQueue); | 621 visitor->trace(m_pendingEventsQueue); |
| 622 visitor->trace(m_executionContext); | 622 visitor->trace(m_executionContext); |
| 623 #endif | 623 #endif |
| 624 EventTargetWithInlineData::trace(visitor); | 624 EventTargetWithInlineData::trace(visitor); |
| 625 } | 625 } |
| 626 | 626 |
| 627 } | 627 } |
| OLD | NEW |