Changeset 125337 in webkit


Ignore:
Timestamp:
Aug 10, 2012, 4:50:46 PM (13 years ago)
Author:
jer.noble@apple.com
Message:

no timeupdate events emitted for media controller
https://bugs.webkit.org/show_bug.cgi?id=93745

Reviewed by Eric Carlson.

Source/WebCore:

Generate timeupdate events while the current position is changing.

Test: media/media-controller-timeupdate.html

Enforce the spec requirement that the timeupdate event is fired no more often
than every 250ms.

  • html/MediaController.cpp:

(MediaController::scheduleTimeupdateEvent):

Add a periodic firing timer to generate timeupdate events during playback.

  • html/MediaController.cpp:

(MediaController::startTimeupdateTimer):
(MediaController::timeupdateTimerFired):

  • html/MediaController.cpp:

(MediaController::MediaController): Initialize m_previousTimeupdateTime.
(MediaController::setCurrentTime): Call scheduleTimeUpdateEvent.
(MediaController::updatePlaybackState): Start and stop the timeupdate timer.

  • html/MediaController.h:

LayoutTests:

New test checking that the timeupdate event is emmitted correctly during playback.

  • media/media-controller-timeupdate-expected.txt: Added.
  • media/media-controller-timeupdate.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125335 r125337  
     12012-08-10  Jer Noble  <jer.noble@apple.com>
     2
     3        no timeupdate events emitted for media controller
     4        https://bugs.webkit.org/show_bug.cgi?id=93745
     5
     6        Reviewed by Eric Carlson.
     7
     8        New test checking that the timeupdate event is emmitted correctly during playback.
     9
     10        * media/media-controller-timeupdate-expected.txt: Added.
     11        * media/media-controller-timeupdate.html: Added.
     12
    1132012-08-09  Jeffrey Pfau  <jpfau@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r125335 r125337  
     12012-08-10  Jer Noble  <jer.noble@apple.com>
     2
     3        no timeupdate events emitted for media controller
     4        https://bugs.webkit.org/show_bug.cgi?id=93745
     5
     6        Reviewed by Eric Carlson.
     7
     8        Generate timeupdate events while the current position is changing.
     9
     10        Test: media/media-controller-timeupdate.html
     11
     12        Enforce the spec requirement that the timeupdate event is fired no more often
     13        than every 250ms.
     14        * html/MediaController.cpp:
     15        (MediaController::scheduleTimeupdateEvent):
     16
     17        Add a periodic firing timer to generate timeupdate events during playback.
     18        * html/MediaController.cpp:
     19        (MediaController::startTimeupdateTimer):
     20        (MediaController::timeupdateTimerFired):
     21
     22        * html/MediaController.cpp:
     23        (MediaController::MediaController): Initialize m_previousTimeupdateTime.
     24        (MediaController::setCurrentTime): Call scheduleTimeUpdateEvent.
     25        (MediaController::updatePlaybackState): Start and stop the timeupdate timer.
     26        * html/MediaController.h:
     27       
    1282012-08-09  Jeffrey Pfau  <jpfau@apple.com>
    229
  • trunk/Source/WebCore/html/MediaController.cpp

    r123386 r125337  
    5757    , m_clock(Clock::create())
    5858    , m_scriptExecutionContext(context)
     59    , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired)
     60    , m_previousTimeupdateTime(0)
    5961{
    6062}
     
    172174    for (size_t index = 0; index < m_mediaElements.size(); ++index)
    173175        m_mediaElements[index]->seek(time, code);
     176
     177    scheduleTimeupdateEvent();
    174178}
    175179
     
    396400        eventName = eventNames().waitingEvent;
    397401        m_clock->stop();
     402        m_timeupdateTimer.stop();
    398403        break;
    399404    case ENDED:
    400405        eventName = eventNames().endedEvent;
    401406        m_clock->stop();
     407        m_timeupdateTimer.stop();
    402408        break;
    403409    case PLAYING:
    404410        eventName = eventNames().playingEvent;
    405411        m_clock->start();
     412        startTimeupdateTimer();
    406413        break;
    407414    default:
     
    606613}
    607614
     615// The spec says to fire periodic timeupdate events (those sent while playing) every
     616// "15 to 250ms", we choose the slowest frequency
     617static const double maxTimeupdateEventFrequency = 0.25;
     618
     619void MediaController::startTimeupdateTimer()
     620{
     621    if (m_timeupdateTimer.isActive())
     622        return;
     623
     624    m_timeupdateTimer.startRepeating(maxTimeupdateEventFrequency);
     625}
     626
     627void MediaController::timeupdateTimerFired(Timer<MediaController>*)
     628{
     629    scheduleTimeupdateEvent();
     630}
     631
     632void MediaController::scheduleTimeupdateEvent()
     633{
     634    double now = WTF::currentTime();
     635    double timedelta = now - m_previousTimeupdateTime;
     636
     637    if (timedelta < maxTimeupdateEventFrequency)
     638        return;
     639
     640    scheduleEvent(eventNames().timeupdateEvent);
     641    m_previousTimeupdateTime = now;
     642}
     643
    608644#endif
  • trunk/Source/WebCore/html/MediaController.h

    r123386 r125337  
    126126    void clearPositionTimerFired(Timer<MediaController>*);
    127127    bool hasEnded() const;
     128    void scheduleTimeupdateEvent();
     129    void timeupdateTimerFired(Timer<MediaController>*);
     130    void startTimeupdateTimer();
    128131
    129132    // EventTarget
     
    153156    PassRefPtr<Clock> m_clock;
    154157    ScriptExecutionContext* m_scriptExecutionContext;
     158    Timer<MediaController> m_timeupdateTimer;
     159    double m_previousTimeupdateTime;
    155160};
    156161
Note: See TracChangeset for help on using the changeset viewer.