| 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 = max(0.0, min(duration(), m_clock->currentTime())); | 154 m_position = max(0.0, min(duration(), m_clock->currentTime())); |
| 155 m_clearPositionTimer.startOneShot(0); | 155 m_clearPositionTimer.startOneShot(0); |
| 156 } | 156 } |
| 157 | 157 |
| 158 return m_position; | 158 return m_position; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void MediaController::setCurrentTime(double time, ExceptionState& es) | 161 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState
) |
| 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 = max(0.0, time); | 166 time = 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 = min(time, duration()); | 170 time = 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_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 (size_t index = 0; index < m_mediaElements.size(); ++index) | 176 for (size_t index = 0; index < m_mediaElements.size(); ++index) |
| 177 m_mediaElements[index]->seek(time, es); | 177 m_mediaElements[index]->seek(time, exceptionState); |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // playback rate to the new value, | 245 // playback rate to the new value, |
| 246 m_clock->setPlayRate(rate); | 246 m_clock->setPlayRate(rate); |
| 247 | 247 |
| 248 for (size_t index = 0; index < m_mediaElements.size(); ++index) | 248 for (size_t index = 0; index < m_mediaElements.size(); ++index) |
| 249 m_mediaElements[index]->updatePlaybackRate(); | 249 m_mediaElements[index]->updatePlaybackRate(); |
| 250 | 250 |
| 251 // then queue a task to fire a simple event named ratechange at the MediaCon
troller. | 251 // then queue a task to fire a simple event named ratechange at the MediaCon
troller. |
| 252 scheduleEvent(EventTypeNames::ratechange); | 252 scheduleEvent(EventTypeNames::ratechange); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void MediaController::setVolume(double level, ExceptionState& es) | 255 void MediaController::setVolume(double level, ExceptionState& exceptionState) |
| 256 { | 256 { |
| 257 if (m_volume == level) | 257 if (m_volume == level) |
| 258 return; | 258 return; |
| 259 | 259 |
| 260 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett
ing, an | 260 // If the new value is outside the range 0.0 to 1.0 inclusive, then, on sett
ing, an |
| 261 // IndexSizeError exception must be raised instead. | 261 // IndexSizeError exception must be raised instead. |
| 262 if (level < 0 || level > 1) { | 262 if (level < 0 || level > 1) { |
| 263 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 263 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 264 return; | 264 return; |
| 265 } | 265 } |
| 266 | 266 |
| 267 // The volume attribute, on setting, if the new value is in the range 0.0 to
1.0 inclusive, | 267 // The volume attribute, on setting, if the new value is in the range 0.0 to
1.0 inclusive, |
| 268 // must set the MediaController's media controller volume multiplier to the
new value | 268 // must set the MediaController's media controller volume multiplier to the
new value |
| 269 m_volume = level; | 269 m_volume = level; |
| 270 | 270 |
| 271 // and queue a task to fire a simple event named volumechange at the MediaCo
ntroller. | 271 // and queue a task to fire a simple event named volumechange at the MediaCo
ntroller. |
| 272 scheduleEvent(EventTypeNames::volumechange); | 272 scheduleEvent(EventTypeNames::volumechange); |
| 273 | 273 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 { | 653 { |
| 654 double now = WTF::currentTime(); | 654 double now = WTF::currentTime(); |
| 655 double timedelta = now - m_previousTimeupdateTime; | 655 double timedelta = now - m_previousTimeupdateTime; |
| 656 | 656 |
| 657 if (timedelta < maxTimeupdateEventFrequency) | 657 if (timedelta < maxTimeupdateEventFrequency) |
| 658 return; | 658 return; |
| 659 | 659 |
| 660 scheduleEvent(EventTypeNames::timeupdate); | 660 scheduleEvent(EventTypeNames::timeupdate); |
| 661 m_previousTimeupdateTime = now; | 661 m_previousTimeupdateTime = now; |
| 662 } | 662 } |
| OLD | NEW |