| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 double MediaController::currentTime() const | 148 double MediaController::currentTime() const |
| 149 { | 149 { |
| 150 if (m_mediaElements.isEmpty()) | 150 if (m_mediaElements.isEmpty()) |
| 151 return 0; | 151 return 0; |
| 152 | 152 |
| 153 if (m_position == MediaPlayer::invalidTime()) { | 153 if (m_position == MediaPlayer::invalidTime()) { |
| 154 // Some clocks may return times outside the range of [0..duration]. | 154 // Some clocks may return times outside the range of [0..duration]. |
| 155 m_position = max(0.0, min(duration(), m_clock->currentTime())); | 155 m_position = max(0.0, min(duration(), m_clock->currentTime())); |
| 156 m_clearPositionTimer.startOneShot(0); | 156 m_clearPositionTimer.startOneShot(0, FROM_HERE); |
| 157 } | 157 } |
| 158 | 158 |
| 159 return m_position; | 159 return m_position; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState
) | 162 void MediaController::setCurrentTime(double time, ExceptionState& exceptionState
) |
| 163 { | 163 { |
| 164 // When the user agent is to seek the media controller to a particular new p
layback position, | 164 // When the user agent is to seek the media controller to a particular new p
layback position, |
| 165 // it must follow these steps: | 165 // it must follow these steps: |
| 166 // If the new playback position is less than zero, then set it to zero. | 166 // If the new playback position is less than zero, then set it to zero. |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 if (!m_mediaElements[index]->ended()) | 532 if (!m_mediaElements[index]->ended()) |
| 533 allHaveEnded = false; | 533 allHaveEnded = false; |
| 534 } | 534 } |
| 535 return allHaveEnded; | 535 return allHaveEnded; |
| 536 } | 536 } |
| 537 | 537 |
| 538 void MediaController::scheduleEvent(const AtomicString& eventName) | 538 void MediaController::scheduleEvent(const AtomicString& eventName) |
| 539 { | 539 { |
| 540 m_pendingEvents.append(Event::createCancelable(eventName)); | 540 m_pendingEvents.append(Event::createCancelable(eventName)); |
| 541 if (!m_asyncEventTimer.isActive()) | 541 if (!m_asyncEventTimer.isActive()) |
| 542 m_asyncEventTimer.startOneShot(0); | 542 m_asyncEventTimer.startOneShot(0, FROM_HERE); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void MediaController::asyncEventTimerFired(Timer<MediaController>*) | 545 void MediaController::asyncEventTimerFired(Timer<MediaController>*) |
| 546 { | 546 { |
| 547 Vector<RefPtr<Event> > pendingEvents; | 547 Vector<RefPtr<Event> > pendingEvents; |
| 548 | 548 |
| 549 m_pendingEvents.swap(pendingEvents); | 549 m_pendingEvents.swap(pendingEvents); |
| 550 size_t count = pendingEvents.size(); | 550 size_t count = pendingEvents.size(); |
| 551 for (size_t index = 0; index < count; ++index) | 551 for (size_t index = 0; index < count; ++index) |
| 552 dispatchEvent(pendingEvents[index].release(), IGNORE_EXCEPTION); | 552 dispatchEvent(pendingEvents[index].release(), IGNORE_EXCEPTION); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 626 |
| 627 // The spec says to fire periodic timeupdate events (those sent while playing) e
very | 627 // The spec says to fire periodic timeupdate events (those sent while playing) e
very |
| 628 // "15 to 250ms", we choose the slowest frequency | 628 // "15 to 250ms", we choose the slowest frequency |
| 629 static const double maxTimeupdateEventFrequency = 0.25; | 629 static const double maxTimeupdateEventFrequency = 0.25; |
| 630 | 630 |
| 631 void MediaController::startTimeupdateTimer() | 631 void MediaController::startTimeupdateTimer() |
| 632 { | 632 { |
| 633 if (m_timeupdateTimer.isActive()) | 633 if (m_timeupdateTimer.isActive()) |
| 634 return; | 634 return; |
| 635 | 635 |
| 636 m_timeupdateTimer.startRepeating(maxTimeupdateEventFrequency); | 636 m_timeupdateTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HERE); |
| 637 } | 637 } |
| 638 | 638 |
| 639 void MediaController::timeupdateTimerFired(Timer<MediaController>*) | 639 void MediaController::timeupdateTimerFired(Timer<MediaController>*) |
| 640 { | 640 { |
| 641 scheduleTimeupdateEvent(); | 641 scheduleTimeupdateEvent(); |
| 642 } | 642 } |
| 643 | 643 |
| 644 void MediaController::scheduleTimeupdateEvent() | 644 void MediaController::scheduleTimeupdateEvent() |
| 645 { | 645 { |
| 646 double now = WTF::currentTime(); | 646 double now = WTF::currentTime(); |
| 647 double timedelta = now - m_previousTimeupdateTime; | 647 double timedelta = now - m_previousTimeupdateTime; |
| 648 | 648 |
| 649 if (timedelta < maxTimeupdateEventFrequency) | 649 if (timedelta < maxTimeupdateEventFrequency) |
| 650 return; | 650 return; |
| 651 | 651 |
| 652 scheduleEvent(EventTypeNames::timeupdate); | 652 scheduleEvent(EventTypeNames::timeupdate); |
| 653 m_previousTimeupdateTime = now; | 653 m_previousTimeupdateTime = now; |
| 654 } | 654 } |
| OLD | NEW |