| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 if (m_position == MediaPlayer::invalidTime()) { | 151 if (m_position == MediaPlayer::invalidTime()) { |
| 152 // Some clocks may return times outside the range of [0..duration]. | 152 // Some clocks may return times outside the range of [0..duration]. |
| 153 m_position = std::max(0.0, std::min(duration(), m_clock->currentTime()))
; | 153 m_position = std::max(0.0, std::min(duration(), m_clock->currentTime()))
; |
| 154 m_clearPositionTimer.startOneShot(0, FROM_HERE); | 154 m_clearPositionTimer.startOneShot(0, FROM_HERE); |
| 155 } | 155 } |
| 156 | 156 |
| 157 return m_position; | 157 return m_position; |
| 158 } | 158 } |
| 159 | 159 |
| 160 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState
) | 160 void MediaController::setCurrentTime(double time) |
| 161 { | 161 { |
| 162 // When the user agent is to seek the media controller to a particular new p
layback position, | 162 // When the user agent is to seek the media controller to a particular new p
layback position, |
| 163 // it must follow these steps: | 163 // it must follow these steps: |
| 164 // If the new playback position is less than zero, then set it to zero. | 164 // If the new playback position is less than zero, then set it to zero. |
| 165 time = std::max(0.0, time); | 165 time = std::max(0.0, time); |
| 166 | 166 |
| 167 // If the new playback position is greater than the media controller duratio
n, then set it | 167 // If the new playback position is greater than the media controller duratio
n, then set it |
| 168 // to the media controller duration. | 168 // to the media controller duration. |
| 169 time = std::min(time, duration()); | 169 time = std::min(time, duration()); |
| 170 | 170 |
| 171 // Set the media controller position to the new playback position. | 171 // Set the media controller position to the new playback position. |
| 172 m_position = time; | 172 m_position = time; |
| 173 m_clock->setCurrentTime(time); | 173 m_clock->setCurrentTime(time); |
| 174 | 174 |
| 175 // Seek each slaved media element to the new playback position relative to t
he media element timeline. | 175 // Seek each slaved media element to the new playback position relative to t
he media element timeline. |
| 176 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it !
= m_mediaElements.end(); ++it) | 176 for (MediaElementSequence::const_iterator it = m_mediaElements.begin(); it !
= m_mediaElements.end(); ++it) |
| 177 (*it)->seek(time, exceptionState); | 177 (*it)->seek(time); |
| 178 | 178 |
| 179 scheduleTimeupdateEvent(); | 179 scheduleTimeupdateEvent(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void MediaController::unpause() | 182 void MediaController::unpause() |
| 183 { | 183 { |
| 184 // When the unpause() method is invoked, if the MediaController is a paused
media controller, | 184 // When the unpause() method is invoked, if the MediaController is a paused
media controller, |
| 185 if (!m_paused) | 185 if (!m_paused) |
| 186 return; | 186 return; |
| 187 | 187 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 } | 476 } |
| 477 | 477 |
| 478 void MediaController::bringElementUpToSpeed(HTMLMediaElement* element) | 478 void MediaController::bringElementUpToSpeed(HTMLMediaElement* element) |
| 479 { | 479 { |
| 480 ASSERT(element); | 480 ASSERT(element); |
| 481 ASSERT(m_mediaElements.contains(element)); | 481 ASSERT(m_mediaElements.contains(element)); |
| 482 | 482 |
| 483 // When the user agent is to bring a media element up to speed with its new
media controller, | 483 // When the user agent is to bring a media element up to speed with its new
media controller, |
| 484 // it must seek that media element to the MediaController's media controller
position relative | 484 // it must seek that media element to the MediaController's media controller
position relative |
| 485 // to the media element's timeline. | 485 // to the media element's timeline. |
| 486 element->seek(currentTime(), IGNORE_EXCEPTION); | 486 element->seek(currentTime()); |
| 487 | 487 |
| 488 // Update volume to take controller volume and mute into account. | 488 // Update volume to take controller volume and mute into account. |
| 489 element->updateVolume(); | 489 element->updateVolume(); |
| 490 } | 490 } |
| 491 | 491 |
| 492 bool MediaController::isRestrained() const | 492 bool MediaController::isRestrained() const |
| 493 { | 493 { |
| 494 ASSERT(!m_mediaElements.isEmpty()); | 494 ASSERT(!m_mediaElements.isEmpty()); |
| 495 | 495 |
| 496 // A MediaController is a restrained media controller if the MediaController
is a playing media | 496 // 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... |
| 617 { | 617 { |
| 618 #if ENABLE(OILPAN) | 618 #if ENABLE(OILPAN) |
| 619 visitor->trace(m_mediaElements); | 619 visitor->trace(m_mediaElements); |
| 620 visitor->trace(m_pendingEventsQueue); | 620 visitor->trace(m_pendingEventsQueue); |
| 621 visitor->trace(m_executionContext); | 621 visitor->trace(m_executionContext); |
| 622 #endif | 622 #endif |
| 623 EventTargetWithInlineData::trace(visitor); | 623 EventTargetWithInlineData::trace(visitor); |
| 624 } | 624 } |
| 625 | 625 |
| 626 } | 626 } |
| OLD | NEW |