Audio element doesn't emit the 'playing' event every time it starts playing, after...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 08:33:21 +0000 (08:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 08:33:21 +0000 (08:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=60972

Patch by Arun Patole <bmf834@motorola.com> on 2011-09-27
Reviewed by Philippe Normand.

Source/WebCore:

The paused attribute should be set to true and the media element should emit a 'paused' at the end of playback.
WHATWG revision r6562: http://html5.org/tools/web-apps-tracker?from=6561&to=6562

Test: media/media-element-play-after-eos.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerTimeChanged): set m_paused to true and schedule 'pause' event when playback ended.

LayoutTests:

Update media tests as the 'pause' event should be fired
and 'paused' should be set to true at the end of playback.

* media/event-attributes-expected.txt:
* media/event-attributes.html:
* media/media-element-play-after-eos-expected.txt: Added.
* media/media-element-play-after-eos.html: Added.
* media/video-loop-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96082 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/event-attributes-expected.txt
LayoutTests/media/event-attributes.html
LayoutTests/media/media-element-play-after-eos-expected.txt [new file with mode: 0644]
LayoutTests/media/media-element-play-after-eos.html [new file with mode: 0644]
LayoutTests/media/video-loop-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp

index a0760ee..e9bee80 100644 (file)
@@ -1,3 +1,19 @@
+2011-09-27  Arun Patole  <bmf834@motorola.com>
+
+        Audio element doesn't emit the 'playing' event every time it starts playing, after it has finished playing.
+        https://bugs.webkit.org/show_bug.cgi?id=60972
+
+        Reviewed by Philippe Normand.
+
+        Update media tests as the 'pause' event should be fired
+        and 'paused' should be set to true at the end of playback.
+
+        * media/event-attributes-expected.txt:
+        * media/event-attributes.html:
+        * media/media-element-play-after-eos-expected.txt: Added.
+        * media/media-element-play-after-eos.html: Added.
+        * media/video-loop-expected.txt:
+
 2011-09-27  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, GTK gardening.
index d8a0612..788637e 100644 (file)
@@ -32,6 +32,7 @@ EVENT(seeked)
 RUN(video.play())
 EVENT(play)
 EVENT(playing)
+EVENT(pause)
 EVENT(ended)
 
 *** played to end, setting 'src' to an invalid movie
index bc9610a..cc32836 100644 (file)
@@ -7,6 +7,7 @@
             var ratechangeCount = 0;
             var playingCount = 0;
             var progressEventCount = 0;
+            var pauseEventCount = 0;
 
             function eventHandler()
             {
                         run("video.pause()");
                         break;
                     case "pause":
-                        consoleWrite("<br>*** seeking");
-                        run("video.currentTime = 5.6");
+                        if(++pauseEventCount == 1) {
+                            consoleWrite("<br>*** seeking");
+                            run("video.currentTime = 5.6");
+                        }
                         break;
                     case "seeked":
                         consoleWrite("<br>*** beginning playback");
diff --git a/LayoutTests/media/media-element-play-after-eos-expected.txt b/LayoutTests/media/media-element-play-after-eos-expected.txt
new file mode 100644 (file)
index 0000000..45163fe
--- /dev/null
@@ -0,0 +1,16 @@
+This tests ensure that media element emits the 'playing' event every time it starts playing after eos. It also ensure that 'pause' and 'ended' events are sent when media playback ends.
+
+RUN(mediaElement.play())
+EVENT(playing)
+EVENT(pause)
+EXPECTED (mediaElement.paused == 'true') OK
+EVENT(ended)
+EXPECTED (mediaElement.ended == 'true') OK
+RUN(mediaElement.play())
+EVENT(playing)
+EVENT(pause)
+EXPECTED (mediaElement.paused == 'true') OK
+EVENT(ended)
+EXPECTED (mediaElement.ended == 'true') OK
+END OF TEST
+
diff --git a/LayoutTests/media/media-element-play-after-eos.html b/LayoutTests/media/media-element-play-after-eos.html
new file mode 100644 (file)
index 0000000..f22c101
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=media-file.js></script>
+        <script src=video-test.js></script>
+        <script>
+            var repeated = false;
+            var mediaElement = new Audio();
+
+            function start()
+            {
+                mediaElement.src = findMediaFile('audio', 'content/silence');
+                run("mediaElement.play()");
+                waitForEvent("playing", mediaPlaying);
+                waitForEvent("pause", mediaPause);
+                waitForEvent("ended", mediaEnded);
+            }
+
+            function mediaPlaying()
+            {
+                mediaElement.currentTime = mediaElement.duration - 0.2;
+            }
+
+            function mediaPause()
+            {
+                testExpected("mediaElement.paused", true);
+            }
+
+            function mediaEnded()
+            {
+                testExpected("mediaElement.ended", true);
+                if (repeated)
+                    endTest();
+                run("mediaElement.play()");
+                repeated = true;
+            }
+
+        </script>
+    </head>
+    <body onload="start()">
+        <p>This tests ensure that media element emits the 'playing' event every time it starts playing after eos. It also ensure that 'pause' and 'ended' events are sent when media playback ends.</p>
+    </body>
+</html>
+
index e091d0a..2e5fa75 100644 (file)
@@ -52,6 +52,7 @@ EXPECTED (video.ended == 'false') OK
 RUN(video.play())
 
 EVENT(play)
+EVENT(pause)
 EVENT(ended)
 
 ++ played to end and stopped.
index 420c94d..83ecfdb 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-27  Arun Patole  <bmf834@motorola.com>
+
+        Audio element doesn't emit the 'playing' event every time it starts playing, after it has finished playing.
+        https://bugs.webkit.org/show_bug.cgi?id=60972
+
+        Reviewed by Philippe Normand.
+
+        The paused attribute should be set to true and the media element should emit a 'paused' at the end of playback.
+        WHATWG revision r6562: http://html5.org/tools/web-apps-tracker?from=6561&to=6562
+
+        Test: media/media-element-play-after-eos.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerTimeChanged): set m_paused to true and schedule 'pause' event when playback ended.
+
 2011-09-27  Rakesh KN  <rakesh.kn@motorola.com>
 
         <input> with autofocus doesn't lose focus when it has a certain onblur listener
index 17d0302..4d426ea 100644 (file)
@@ -2139,6 +2139,10 @@ void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*)
             m_sentEndEvent = false;
             seek(0, ignoredException);
         } else {
+            if (!m_paused) {
+                m_paused = true;
+                scheduleEvent(eventNames().pauseEvent);
+            }
             if (!m_sentEndEvent) {
                 m_sentEndEvent = true;
                 scheduleEvent(eventNames().endedEvent);