Title: [119739] trunk
Revision
119739
Author
jer.no...@apple.com
Date
2012-06-07 11:18:37 -0700 (Thu, 07 Jun 2012)

Log Message

sometimes all slaved videos don't start playing
https://bugs.webkit.org/show_bug.cgi?id=88553

Reviewed by Darin Adler.

Source/WebCore:

Test: media/media-controller-time-clamp.html

Some PlatformClock classes will occasionally return times < 0 and will
always return times slightly > duration() when playback has ended.  Clamp
the value of currentTime() to the specified [0..duration] range.

* html/MediaController.cpp:
(MediaController::currentTime):

LayoutTests:

* media/media-controller-time-clamp-expected.txt: Added.
* media/media-controller-time-clamp.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119738 => 119739)


--- trunk/LayoutTests/ChangeLog	2012-06-07 18:02:40 UTC (rev 119738)
+++ trunk/LayoutTests/ChangeLog	2012-06-07 18:18:37 UTC (rev 119739)
@@ -1,3 +1,13 @@
+2012-06-07  Jer Noble  <jer.no...@apple.com>
+
+        sometimes all slaved videos don't start playing
+        https://bugs.webkit.org/show_bug.cgi?id=88553
+
+        Reviewed by Darin Adler.
+
+        * media/media-controller-time-clamp-expected.txt: Added.
+        * media/media-controller-time-clamp.html: Added.
+
 2012-06-07  Ojan Vafai  <o...@chromium.org>
 
         Mark another test as slow on Chromium Windows.

Added: trunk/LayoutTests/media/media-controller-time-clamp-expected.txt (0 => 119739)


--- trunk/LayoutTests/media/media-controller-time-clamp-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-controller-time-clamp-expected.txt	2012-06-07 18:18:37 UTC (rev 119739)
@@ -0,0 +1,9 @@
+RUN(controller = video.controller)
+EVENT(canplaythrough)
+RUN(controller.currentTime = controller.duration - 0.05)
+RUN(video.play())
+RUN(controller.play())
+EVENT(ended)
+EXPECTED (controller.currentTime <= controller.duration == 'true') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/media-controller-time-clamp.html (0 => 119739)


--- trunk/LayoutTests/media/media-controller-time-clamp.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-controller-time-clamp.html	2012-06-07 18:18:37 UTC (rev 119739)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script src=""
+
+        <script>
+        var controller;
+        var video;
+
+        function start() {
+            video = document.getElementById('video');
+            run('controller = video.controller');
+            controller.addEventListener('canplaythrough', canplaythrough, true);
+            var src = "" 'content/test');
+            video.src = ""
+        }
+        
+        function canplaythrough() {
+            consoleWrite("EVENT(canplaythrough)");
+            controller.removeEventListener('canplaythrough', canplaythrough, true);
+            controller.addEventListener('ended', ended, true);
+            // 0.05 is greater than one frame of this 25fps video.
+            run('controller.currentTime = controller.duration - 0.05');
+            run('video.play()');
+            run('controller.play()');
+        }
+        
+        function ended() { 
+            consoleWrite("EVENT(ended)");
+            testExpected("controller.currentTime <= controller.duration", true);
+            endTest();
+        }
+        </script>
+    </head>
+    <body _onload_="start()">
+        <video id="video" mediaGroup="group" controls></video>
+    </body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (119738 => 119739)


--- trunk/Source/WebCore/ChangeLog	2012-06-07 18:02:40 UTC (rev 119738)
+++ trunk/Source/WebCore/ChangeLog	2012-06-07 18:18:37 UTC (rev 119739)
@@ -1,3 +1,19 @@
+2012-06-07  Jer Noble  <jer.no...@apple.com>
+
+        sometimes all slaved videos don't start playing
+        https://bugs.webkit.org/show_bug.cgi?id=88553
+
+        Reviewed by Darin Adler.
+
+        Test: media/media-controller-time-clamp.html
+
+        Some PlatformClock classes will occasionally return times < 0 and will
+        always return times slightly > duration() when playback has ended.  Clamp
+        the value of currentTime() to the specified [0..duration] range.
+
+        * html/MediaController.cpp:
+        (MediaController::currentTime):
+
 2012-06-07  Simon Fraser  <simon.fra...@apple.com>
 
         Optimize FrameView::scrollXForFixedPosition() / scrollYForFixedPosition()

Modified: trunk/Source/WebCore/html/MediaController.cpp (119738 => 119739)


--- trunk/Source/WebCore/html/MediaController.cpp	2012-06-07 18:02:40 UTC (rev 119738)
+++ trunk/Source/WebCore/html/MediaController.cpp	2012-06-07 18:18:37 UTC (rev 119739)
@@ -142,8 +142,9 @@
 {
     if (m_mediaElements.isEmpty())
         return 0;
-    
-    return m_clock->currentTime();
+
+    // Some clocks may return times outside the range of [0..duration].
+    return max(0.0f, min(duration(), m_clock->currentTime()));
 }
 
 void MediaController::setCurrentTime(float time, ExceptionCode& code)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to