[Qt][Gtk] Wrong state when pausing a video in the "playing" event handler
authoryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 14:03:46 +0000 (14:03 +0000)
committeryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 14:03:46 +0000 (14:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68589

Reviewed by Philippe Normand.

Source/WebCore:

Test: media/video-playing-and-pause.html

As suggested by Alexis Menard on IRC, query gstreamer's state instead of using a cached value
in MediaPlayerGstreamerPrivate::paused().

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::paused):

LayoutTests:

* media/video-playing-and-pause.html: Added.
* media/video-paint-test.js:
* platform/qt/media/video-playing-and-pause-expected.txt: Added.
* platform/qt/media/video-playing-and-pause-expected.png: Added.

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

LayoutTests/ChangeLog
LayoutTests/media/video-paint-test.js
LayoutTests/media/video-playing-and-pause.html [new file with mode: 0644]
LayoutTests/platform/qt/media/video-playing-and-pause-expected.png [new file with mode: 0644]
LayoutTests/platform/qt/media/video-playing-and-pause-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

index b1fe1b8..def0950 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-23  Yael Aharon  <yael.aharon@nokia.com>
+
+        [Qt][Gtk] Wrong state when pausing a video in the "playing" event handler
+        https://bugs.webkit.org/show_bug.cgi?id=68589
+
+        Reviewed by Philippe Normand.
+
+        * media/video-playing-and-pause.html: Added.
+        * media/video-paint-test.js:
+        * platform/qt/media/video-playing-and-pause-expected.txt: Added.
+        * platform/qt/media/video-playing-and-pause-expected.png: Added.
+
 2011-09-23  Marcus Bulach  <bulach@chromium.org>
 
         [chromium, gtk, qt] Rebaseline following r95726
index f4f0694..06a0965 100644 (file)
@@ -27,3 +27,23 @@ if (window.layoutTestController) {
             layoutTestController.notifyDone();
     } , 8000);
 }
+
+function initAndPause()
+{
+    var totalCount = document.getElementsByTagName('video').length;
+    var count = totalCount;
+    document.addEventListener("canplaythrough", function () {
+        if (!--count) {
+            var video = document.getElementsByTagName('video')[0];
+            video.play();
+            video.addEventListener("playing", function() {
+                video.pause();
+                video.addEventListener("pause", function() {
+                    if (window.layoutTestController)
+                        layoutTestController.notifyDone();
+                });
+            });
+        }
+    }, true);
+}
+
diff --git a/LayoutTests/media/video-playing-and-pause.html b/LayoutTests/media/video-playing-and-pause.html
new file mode 100644 (file)
index 0000000..d00fa97
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html>
+    <head>
+        <script src="media-file.js"></script>
+        <script src="video-paint-test.js"></script>
+    </head>
+    <body onload="setSrcByTagName('video', findMediaFile('video', 'content/test')); initAndPause()">
+        <p>Test that pausing the media element in "playing" event handler pauses the media immediately. The video should show the first frame.</p>
+        <video controls></video>
+    </body>
+</html>
+
diff --git a/LayoutTests/platform/qt/media/video-playing-and-pause-expected.png b/LayoutTests/platform/qt/media/video-playing-and-pause-expected.png
new file mode 100644 (file)
index 0000000..3955302
Binary files /dev/null and b/LayoutTests/platform/qt/media/video-playing-and-pause-expected.png differ
diff --git a/LayoutTests/platform/qt/media/video-playing-and-pause-expected.txt b/LayoutTests/platform/qt/media/video-playing-and-pause-expected.txt
new file mode 100644 (file)
index 0000000..d0b6c41
--- /dev/null
@@ -0,0 +1,33 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x330
+  RenderBlock {HTML} at (0,0) size 800x330
+    RenderBody {BODY} at (8,16) size 784x306
+      RenderBlock {P} at (0,0) size 784x44
+        RenderText {#text} at (0,0) size 758x44
+          text run at (0,0) width 758: "Test that pausing the media element in \"playing\" event handler pauses the media immediately. The video should"
+          text run at (0,22) width 139: "show the first frame."
+      RenderBlock (anonymous) at (0,60) size 784x246
+        RenderText {#text} at (0,0) size 0x0
+layer at (8,76) size 320x240
+  RenderVideo {VIDEO} at (0,0) size 320x240
+layer at (8,76) size 320x240
+  RenderBlock (relative positioned) {DIV} at (0,0) size 320x240
+layer at (8,76) size 320x240
+  RenderDeprecatedFlexibleBox (positioned) {DIV} at (0,0) size 320x240
+    RenderButton {INPUT} at (5,211) size 32x24
+    RenderDeprecatedFlexibleBox {DIV} at (40,206) size 216x34
+      RenderBlock (anonymous) at (0,0) size 81x34
+      RenderSlider {INPUT} at (84,5) size 129x24
+        RenderDeprecatedFlexibleBox {DIV} at (8,6) size 113x12
+          RenderBlock {DIV} at (0,0) size 109x12
+          RenderBlock {DIV} at (109,0) size 4x12
+    RenderButton {INPUT} at (259,211) size 24x24
+    RenderButton {INPUT} at (291,211) size 24x24
+layer at (51,287) size 75x24 scrollHeight 26
+  RenderDeprecatedFlexibleBox {DIV} at (3,5) size 75x24 [color=#FFFFFF]
+    RenderBlock (anonymous) at (6,6) size 63x12
+      RenderText {#text} at (0,0) size 63x14
+        text run at (0,0) width 63: "00:00 / 00:06"
+layer at (140,293) size 4x12
+  RenderBlock (relative positioned) {DIV} at (0,0) size 4x12
index 987b6cc..6b88ef5 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-23  Yael Aharon  <yael.aharon@nokia.com>
+
+        [Qt][Gtk] Wrong state when pausing a video in the "playing" event handler
+        https://bugs.webkit.org/show_bug.cgi?id=68589
+
+        Reviewed by Philippe Normand.
+
+        Test: media/video-playing-and-pause.html
+
+        As suggested by Alexis Menard on IRC, query gstreamer's state instead of using a cached value
+        in MediaPlayerGstreamerPrivate::paused(). 
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::paused):
+
 2011-09-15  Pavel Podivilov  <podivilov@chromium.org>
 
         Web Inspector: skip overlapping scripts when displaying concatenated content.
index 2bbd3a0..4ae39f7 100644 (file)
@@ -455,7 +455,9 @@ void MediaPlayerPrivateGStreamer::seek(float time)
 
 bool MediaPlayerPrivateGStreamer::paused() const
 {
-    return m_paused;
+    GstState state;
+    gst_element_get_state(m_playBin, &state, 0, 0);
+    return state == GST_STATE_PAUSED;
 }
 
 bool MediaPlayerPrivateGStreamer::seeking() const