Title: [158965] trunk
Revision
158965
Author
commit-qu...@webkit.org
Date
2013-11-08 15:45:22 -0800 (Fri, 08 Nov 2013)

Log Message

Ended event should work also when playback rate is negative
https://bugs.webkit.org/show_bug.cgi?id=123879

Patch by Piotr Grad <p.g...@samsung.com> on 2013-11-08
Reviewed by Eric Carlson.

Source/WebCore:

According to W3C specification playback is ended also when playback rate is
negative and position is the earliest possible position.

Test: media/video-ended-event-negative-playback.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerTimeChanged):

LayoutTests:

Tests if ended event is triggered for audio/video elements after
changing playback rate to negative.

* media/video-ended-event-negative-playback-expected.txt: Added.
* media/video-ended-event-negative-playback.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (158964 => 158965)


--- trunk/LayoutTests/ChangeLog	2013-11-08 23:36:31 UTC (rev 158964)
+++ trunk/LayoutTests/ChangeLog	2013-11-08 23:45:22 UTC (rev 158965)
@@ -1,3 +1,16 @@
+2013-11-08  Piotr Grad  <p.g...@samsung.com>
+
+        Ended event should work also when playback rate is negative
+        https://bugs.webkit.org/show_bug.cgi?id=123879
+
+        Reviewed by Eric Carlson.
+
+        Tests if ended event is triggered for audio/video elements after
+        changing playback rate to negative.
+
+        * media/video-ended-event-negative-playback-expected.txt: Added.
+        * media/video-ended-event-negative-playback.html: Added.
+
 2013-11-08  Thiago de Barros Lacerda  <thiago.lace...@openbossa.org>
 
         Checking for TypeError in RTCPeerConnection object creation

Added: trunk/LayoutTests/media/video-ended-event-negative-playback-expected.txt (0 => 158965)


--- trunk/LayoutTests/media/video-ended-event-negative-playback-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-ended-event-negative-playback-expected.txt	2013-11-08 23:45:22 UTC (rev 158965)
@@ -0,0 +1,5 @@
+
+EVENT(canplaythrough)
+EVENT(ended)
+END OF TEST
+

Added: trunk/LayoutTests/media/video-ended-event-negative-playback.html (0 => 158965)


--- trunk/LayoutTests/media/video-ended-event-negative-playback.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-ended-event-negative-playback.html	2013-11-08 23:45:22 UTC (rev 158965)
@@ -0,0 +1,24 @@
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script>
+            function start() {
+                findMediaElement();
+                waitForEventAndEnd('ended');
+                video.src = "" "content/test");
+                waitForEventOnce('canplaythrough',
+                    function ()
+                    {
+                        video.currentTime = 0.5;
+                        video.playbackRate = -1;
+                        video.play();
+                        failTestIn(2500);
+                    });
+                }
+        </script>
+    </head>
+    <body _onload_="start()">
+        <video loop />
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (158964 => 158965)


--- trunk/Source/WebCore/ChangeLog	2013-11-08 23:36:31 UTC (rev 158964)
+++ trunk/Source/WebCore/ChangeLog	2013-11-08 23:45:22 UTC (rev 158965)
@@ -1,3 +1,18 @@
+2013-11-08  Piotr Grad  <p.g...@samsung.com>
+
+        Ended event should work also when playback rate is negative
+        https://bugs.webkit.org/show_bug.cgi?id=123879
+
+        Reviewed by Eric Carlson.
+
+        According to W3C specification playback is ended also when playback rate is
+        negative and position is the earliest possible position.
+
+        Test: media/video-ended-event-negative-playback.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
+
 2013-11-08  Thiago de Barros Lacerda  <thiago.lace...@openbossa.org>
 
         Checking for TypeError in RTCPeerConnection object creation

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (158964 => 158965)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-11-08 23:36:31 UTC (rev 158964)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-11-08 23:45:22 UTC (rev 158965)
@@ -3663,18 +3663,18 @@
     double now = currentTime();
     double dur = duration();
     
-    // When the current playback position reaches the end of the media resource when the direction of
-    // playback is forwards, then the user agent must follow these steps:
-    if (!std::isnan(dur) && dur && now >= dur && m_playbackRate > 0) {
+    // When the current playback position reaches the end of the media resource then the user agent must follow these steps:
+    if (!std::isnan(dur) && dur) {
         // If the media element has a loop attribute specified and does not have a current media controller,
-        if (loop() && !m_mediaController) {
+        if (loop() && !m_mediaController && m_playbackRate > 0) {
             m_sentEndEvent = false;
-            //  then seek to the earliest possible position of the media resource and abort these steps.
-            seek(0, IGNORE_EXCEPTION);
-        } else {
+            // then seek to the earliest possible position of the media resource and abort these steps when the direction of
+            // playback is forwards,
+            if (now >= dur)
+                seek(0, IGNORE_EXCEPTION);
+        } else if ((now <= 0 && m_playbackRate < 0) || (now >= dur && m_playbackRate > 0)) {
             // If the media element does not have a current media controller, and the media element
-            // has still ended playback, and the direction of playback is still forwards, and paused
-            // is false,
+            // has still ended playback and paused is false,
             if (!m_mediaController && !m_paused) {
                 // changes paused to true and fires a simple event named pause at the media element.
                 m_paused = true;
@@ -3688,7 +3688,8 @@
             // If the media element has a current media controller, then report the controller state
             // for the media element's current media controller.
             updateMediaController();
-        }
+        } else
+            m_sentEndEvent = false;
     }
     else
         m_sentEndEvent = false;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to