Title: [125337] trunk
Revision
125337
Author
[email protected]
Date
2012-08-10 16:50:46 -0700 (Fri, 10 Aug 2012)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125336 => 125337)


--- trunk/LayoutTests/ChangeLog	2012-08-10 23:33:55 UTC (rev 125336)
+++ trunk/LayoutTests/ChangeLog	2012-08-10 23:50:46 UTC (rev 125337)
@@ -1,3 +1,15 @@
+2012-08-10  Jer Noble  <[email protected]>
+
+        no timeupdate events emitted for media controller
+        https://bugs.webkit.org/show_bug.cgi?id=93745
+
+        Reviewed by Eric Carlson.
+
+        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.
+
 2012-08-09  Jeffrey Pfau  <[email protected]>
 
         Allow blocking of third-party localStorage and sessionStorage

Added: trunk/LayoutTests/media/media-controller-timeupdate-expected.txt (0 => 125337)


--- trunk/LayoutTests/media/media-controller-timeupdate-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-controller-timeupdate-expected.txt	2012-08-10 23:50:46 UTC (rev 125337)
@@ -0,0 +1,5 @@
+EVENT(canplay)
+RUN(video.play)
+EVENT(timeupdate)
+END OF TEST
+

Added: trunk/LayoutTests/media/media-controller-timeupdate.html (0 => 125337)


--- trunk/LayoutTests/media/media-controller-timeupdate.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-controller-timeupdate.html	2012-08-10 23:50:46 UTC (rev 125337)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>MediaController - timeupdate test</title>
+    <script src=""
+    <script src=""
+    <script>
+        var video;
+
+        var start = function() {
+            findMediaElement();
+            
+            waitForEvent('canplay', canplay);
+            video.src = "" "content/test");
+        };
+        
+        var canplay = function() {
+            waitForEventAndEnd('timeupdate');
+            run('video.play');
+        };
+    </script>
+</head>
+<body>
+    <body _onload_="start()">
+        <video id="video" mediaGroup="group" controls autoplay></video>
+    </body>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (125336 => 125337)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 23:33:55 UTC (rev 125336)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 23:50:46 UTC (rev 125337)
@@ -1,3 +1,30 @@
+2012-08-10  Jer Noble  <[email protected]>
+
+        no timeupdate events emitted for media controller
+        https://bugs.webkit.org/show_bug.cgi?id=93745
+
+        Reviewed by Eric Carlson.
+
+        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:
+        
 2012-08-09  Jeffrey Pfau  <[email protected]>
 
         Allow blocking of third-party localStorage and sessionStorage

Modified: trunk/Source/WebCore/html/MediaController.cpp (125336 => 125337)


--- trunk/Source/WebCore/html/MediaController.cpp	2012-08-10 23:33:55 UTC (rev 125336)
+++ trunk/Source/WebCore/html/MediaController.cpp	2012-08-10 23:50:46 UTC (rev 125337)
@@ -56,6 +56,8 @@
     , m_closedCaptionsVisible(false)
     , m_clock(Clock::create())
     , m_scriptExecutionContext(context)
+    , m_timeupdateTimer(this, &MediaController::timeupdateTimerFired)
+    , m_previousTimeupdateTime(0)
 {
 }
 
@@ -171,6 +173,8 @@
     // Seek each slaved media element to the new playback position relative to the media element timeline.
     for (size_t index = 0; index < m_mediaElements.size(); ++index)
         m_mediaElements[index]->seek(time, code);
+
+    scheduleTimeupdateEvent();
 }
 
 void MediaController::play()
@@ -395,14 +399,17 @@
     case WAITING:
         eventName = eventNames().waitingEvent;
         m_clock->stop();
+        m_timeupdateTimer.stop();
         break;
     case ENDED:
         eventName = eventNames().endedEvent;
         m_clock->stop();
+        m_timeupdateTimer.stop();
         break;
     case PLAYING:
         eventName = eventNames().playingEvent;
         m_clock->start();
+        startTimeupdateTimer();
         break;
     default:
         ASSERT_NOT_REACHED();
@@ -605,4 +612,33 @@
     return eventNames().interfaceForMediaController;
 }
 
+// The spec says to fire periodic timeupdate events (those sent while playing) every
+// "15 to 250ms", we choose the slowest frequency
+static const double maxTimeupdateEventFrequency = 0.25;
+
+void MediaController::startTimeupdateTimer()
+{
+    if (m_timeupdateTimer.isActive())
+        return;
+
+    m_timeupdateTimer.startRepeating(maxTimeupdateEventFrequency);
+}
+
+void MediaController::timeupdateTimerFired(Timer<MediaController>*)
+{
+    scheduleTimeupdateEvent();
+}
+
+void MediaController::scheduleTimeupdateEvent()
+{
+    double now = WTF::currentTime();
+    double timedelta = now - m_previousTimeupdateTime;
+
+    if (timedelta < maxTimeupdateEventFrequency)
+        return;
+
+    scheduleEvent(eventNames().timeupdateEvent);
+    m_previousTimeupdateTime = now;
+}
+
 #endif

Modified: trunk/Source/WebCore/html/MediaController.h (125336 => 125337)


--- trunk/Source/WebCore/html/MediaController.h	2012-08-10 23:33:55 UTC (rev 125336)
+++ trunk/Source/WebCore/html/MediaController.h	2012-08-10 23:50:46 UTC (rev 125337)
@@ -125,6 +125,9 @@
     void asyncEventTimerFired(Timer<MediaController>*);
     void clearPositionTimerFired(Timer<MediaController>*);
     bool hasEnded() const;
+    void scheduleTimeupdateEvent();
+    void timeupdateTimerFired(Timer<MediaController>*);
+    void startTimeupdateTimer();
 
     // EventTarget
     virtual void refEventTarget() { ref(); }
@@ -152,6 +155,8 @@
     bool m_closedCaptionsVisible;
     PassRefPtr<Clock> m_clock;
     ScriptExecutionContext* m_scriptExecutionContext;
+    Timer<MediaController> m_timeupdateTimer;
+    double m_previousTimeupdateTime;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to