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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 PassRefPtrWillBeRawPtr<MediaController> MediaController::create(ExecutionContext
* context) | 45 PassRefPtrWillBeRawPtr<MediaController> MediaController::create(ExecutionContext
* context) |
46 { | 46 { |
47 return adoptRefWillBeNoop(new MediaController(context)); | 47 return adoptRefWillBeNoop(new MediaController(context)); |
48 } | 48 } |
49 | 49 |
50 MediaController::MediaController(ExecutionContext* context) | 50 MediaController::MediaController(ExecutionContext* context) |
51 : m_paused(false) | 51 : m_paused(false) |
52 , m_defaultPlaybackRate(1) | 52 , m_defaultPlaybackRate(1) |
53 , m_volume(1) | 53 , m_volume(1) |
54 , m_position(MediaPlayer::invalidTime()) | 54 , m_position(std::numeric_limits<double>::quiet_NaN()) |
55 , m_muted(false) | 55 , m_muted(false) |
56 , m_readyState(HTMLMediaElement::HAVE_NOTHING) | 56 , m_readyState(HTMLMediaElement::HAVE_NOTHING) |
57 , m_playbackState(WAITING) | 57 , m_playbackState(WAITING) |
58 , m_pendingEventsQueue(GenericEventQueue::create(this)) | 58 , m_pendingEventsQueue(GenericEventQueue::create(this)) |
59 , m_clearPositionTimer(this, &MediaController::clearPositionTimerFired) | 59 , m_clearPositionTimer(this, &MediaController::clearPositionTimerFired) |
60 , m_clock(Clock::create()) | 60 , m_clock(Clock::create()) |
61 , m_executionContext(context) | 61 , m_executionContext(context) |
62 , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired) | 62 , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired) |
63 , m_previousTimeupdateTime(0) | 63 , m_previousTimeupdateTime(0) |
64 { | 64 { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 maxDuration = std::max(maxDuration, duration); | 141 maxDuration = std::max(maxDuration, duration); |
142 } | 142 } |
143 return maxDuration; | 143 return maxDuration; |
144 } | 144 } |
145 | 145 |
146 double MediaController::currentTime() const | 146 double MediaController::currentTime() const |
147 { | 147 { |
148 if (m_mediaElements.isEmpty()) | 148 if (m_mediaElements.isEmpty()) |
149 return 0; | 149 return 0; |
150 | 150 |
151 if (m_position == MediaPlayer::invalidTime()) { | 151 if (std::isnan(m_position)) { |
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) | 160 void MediaController::setCurrentTime(double time) |
161 { | 161 { |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 return allHaveEnded; | 561 return allHaveEnded; |
562 } | 562 } |
563 | 563 |
564 void MediaController::scheduleEvent(const AtomicString& eventName) | 564 void MediaController::scheduleEvent(const AtomicString& eventName) |
565 { | 565 { |
566 m_pendingEventsQueue->enqueueEvent(Event::createCancelable(eventName)); | 566 m_pendingEventsQueue->enqueueEvent(Event::createCancelable(eventName)); |
567 } | 567 } |
568 | 568 |
569 void MediaController::clearPositionTimerFired(Timer<MediaController>*) | 569 void MediaController::clearPositionTimerFired(Timer<MediaController>*) |
570 { | 570 { |
571 m_position = MediaPlayer::invalidTime(); | 571 m_position = std::numeric_limits<double>::quiet_NaN(); |
572 } | 572 } |
573 | 573 |
574 const AtomicString& MediaController::interfaceName() const | 574 const AtomicString& MediaController::interfaceName() const |
575 { | 575 { |
576 return EventTargetNames::MediaController; | 576 return EventTargetNames::MediaController; |
577 } | 577 } |
578 | 578 |
579 // The spec says to fire periodic timeupdate events (those sent while playing) e
very | 579 // The spec says to fire periodic timeupdate events (those sent while playing) e
very |
580 // "15 to 250ms", we choose the slowest frequency | 580 // "15 to 250ms", we choose the slowest frequency |
581 static const double maxTimeupdateEventFrequency = 0.25; | 581 static const double maxTimeupdateEventFrequency = 0.25; |
(...skipping 27 matching lines...) Expand all Loading... |
609 { | 609 { |
610 #if ENABLE(OILPAN) | 610 #if ENABLE(OILPAN) |
611 visitor->trace(m_mediaElements); | 611 visitor->trace(m_mediaElements); |
612 visitor->trace(m_pendingEventsQueue); | 612 visitor->trace(m_pendingEventsQueue); |
613 visitor->trace(m_executionContext); | 613 visitor->trace(m_executionContext); |
614 #endif | 614 #endif |
615 EventTargetWithInlineData::trace(visitor); | 615 EventTargetWithInlineData::trace(visitor); |
616 } | 616 } |
617 | 617 |
618 } | 618 } |
OLD | NEW |