Title: [116858] trunk
- Revision
- 116858
- Author
- [email protected]
- Date
- 2012-05-12 10:09:59 -0700 (Sat, 12 May 2012)
Log Message
[BlackBerry] Allow the platform media player to determine the media element's paused/playing status
https://bugs.webkit.org/show_bug.cgi?id=86235
Patch by Max Feil <[email protected]> on 2012-05-12
Reviewed by George Staikos.
Source/WebCore:
The platform media player needs to know when the HTMLMediaElement
is not paused. This is to address problems when switching
source element, which causes the destruction of the old
MediaPlayerPrivate object and construction of a new one. The
new one must resume playing ASAP if the old one was playing.
Test: media/media-continues-playing-after-replace-source.html
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
(WebCore::MediaPlayerPrivate::isElementPaused):
(WebCore):
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
(MediaPlayerPrivate):
LayoutTests:
This test replaces the source element of a playing media object
and makes sure the new source element begins playing.
* media/media-continues-playing-after-replace-source-expected.txt: Added.
* media/media-continues-playing-after-replace-source.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (116857 => 116858)
--- trunk/LayoutTests/ChangeLog 2012-05-12 16:35:48 UTC (rev 116857)
+++ trunk/LayoutTests/ChangeLog 2012-05-12 17:09:59 UTC (rev 116858)
@@ -1,3 +1,16 @@
+2012-05-12 Max Feil <[email protected]>
+
+ [BlackBerry] Allow the platform media player to determine the media element's paused/playing status
+ https://bugs.webkit.org/show_bug.cgi?id=86235
+
+ Reviewed by George Staikos.
+
+ This test replaces the source element of a playing media object
+ and makes sure the new source element begins playing.
+
+ * media/media-continues-playing-after-replace-source-expected.txt: Added.
+ * media/media-continues-playing-after-replace-source.html: Added.
+
2012-05-12 Zan Dobersek <[email protected]>
Unreviewed, GTK gardening. Also add baselines for new tests after
Added: trunk/LayoutTests/media/media-continues-playing-after-replace-source-expected.txt (0 => 116858)
--- trunk/LayoutTests/media/media-continues-playing-after-replace-source-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-continues-playing-after-replace-source-expected.txt 2012-05-12 17:09:59 UTC (rev 116858)
@@ -0,0 +1,11 @@
+Test that media keeps playing when the source element is replaced.
+
+EVENT(canplaythrough)
+EXPECTED (testElement.currentTime == '0') OK
+EVENT(playing)
+EXPECTED (testElement.currentTime > '0') OK
+Replacing the media's source element:
+EXPECTED (testElement.currentTime == '0') OK
+EXPECTED (testElement.currentTime > '0') OK
+END OF TEST
+
Added: trunk/LayoutTests/media/media-continues-playing-after-replace-source.html (0 => 116858)
--- trunk/LayoutTests/media/media-continues-playing-after-replace-source.html (rev 0)
+++ trunk/LayoutTests/media/media-continues-playing-after-replace-source.html 2012-05-12 17:09:59 UTC (rev 116858)
@@ -0,0 +1,108 @@
+<html>
+ <title>Test media source replacement</title>
+ <body>
+
+ <p>Test that media keeps playing when the source element is replaced.</p>
+
+ <script src=""
+ <script src=""
+ <script>
+ var timeupdateEventCount = 0;
+ var skippedCount = 0;
+ var sourceReplaced = false;
+
+ function swapAudio() {
+ v = document.getElementsByTagName('audio')[0];
+ v.removeChild(v.childNodes[0]);
+ var s = document.createElement('source');
+ s.src = "" "content/test");
+ v.appendChild(s);
+ }
+
+ function errorListener(event)
+ {
+ logResult(false, "Caught 'error' event, audio.error.code = " + this.error.code);
+ endTest();
+ }
+
+ function canplaythroughListener(event)
+ {
+ consoleWrite("EVENT(canplaythrough)");
+ testElement = this;
+ testExpected("testElement.currentTime", 0);
+ this.play();
+ }
+
+ function playingListener(event)
+ {
+ consoleWrite("EVENT(playing)");
+ }
+
+ function timeupdateListener(event)
+ {
+ ++timeupdateEventCount;
+
+ if (timeupdateEventCount-skippedCount == 1) {
+ // First time update after source replacement should be 0.
+ // We allow one late time update to come in from the previous
+ // source element. This was done to help the cr-linux test
+ // pass, and does not necessarily indicate a problem.
+ if (sourceReplaced) {
+ if (skippedCount >= 1 || this.currentTime == 0) {
+ testElement = this;
+ testExpected("testElement.currentTime", 0);
+ } else {
+ // The time is not 0 as expected. Hope this is a
+ // late update from the previous source.
+ ++skippedCount;
+ }
+ }
+ } else if (timeupdateEventCount-skippedCount >= 2) {
+ // We wait 2 timeupdate events so we are sure the media engine
+ // is playing the media, and make sure time is advancing.
+ testElement = this;
+ testExpected("testElement.currentTime", 0, '>');
+ if (!sourceReplaced) {
+ consoleWrite("Replacing the media's source element:");
+ sourceReplaced = true;
+ timeupdateEventCount = 0;
+ skippedCount = 0;
+ // The ports are not consistent in regards to whether
+ // the canplaythrough and playing events are triggered
+ // a second time, so stop listening for them. This was
+ // done to help the cr-linux test pass, and does not
+ // necessarily indicate a problem.
+ this.removeEventListener('playing', playingListener);
+ this.removeEventListener('canplaythrough', canplaythroughListener);
+ swapAudio();
+ } else {
+ this.removeEventListener('timeupdate', timeupdateListener);
+ this.pause();
+ endTest();
+ }
+ }
+ }
+
+ function testAudioElement(count)
+ {
+ timeupdateEventCount = 0;
+ skippedCount = 0;
+ var audioElement = document.getElementsByTagName('audio')[count];
+ //audioElement.removeChild(audioElement.childNodes[0]);
+ audioElement.addEventListener('error', errorListener);
+ audioElement.addEventListener('canplaythrough', canplaythroughListener);
+ audioElement.addEventListener('timeupdate', timeupdateListener);
+ audioElement.addEventListener('playing', playingListener);
+
+ var s = document.createElement('source');
+ s.src = "" "content/silence");
+ audioElement.appendChild(s);
+
+ }
+
+ document.write("<audio controls></audio>");
+ testAudioElement(0);
+ </script>
+
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (116857 => 116858)
--- trunk/Source/WebCore/ChangeLog 2012-05-12 16:35:48 UTC (rev 116857)
+++ trunk/Source/WebCore/ChangeLog 2012-05-12 17:09:59 UTC (rev 116858)
@@ -1,3 +1,24 @@
+2012-05-12 Max Feil <[email protected]>
+
+ [BlackBerry] Allow the platform media player to determine the media element's paused/playing status
+ https://bugs.webkit.org/show_bug.cgi?id=86235
+
+ Reviewed by George Staikos.
+
+ The platform media player needs to know when the HTMLMediaElement
+ is not paused. This is to address problems when switching
+ source element, which causes the destruction of the old
+ MediaPlayerPrivate object and construction of a new one. The
+ new one must resume playing ASAP if the old one was playing.
+
+ Test: media/media-continues-playing-after-replace-source.html
+
+ * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
+ (WebCore::MediaPlayerPrivate::isElementPaused):
+ (WebCore):
+ * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
+ (MediaPlayerPrivate):
+
2012-05-12 Yury Semikhatsky <[email protected]>
Web Inspector: heap profiler should allow revealing an element which is logged to the console
Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp (116857 => 116858)
--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp 2012-05-12 16:35:48 UTC (rev 116857)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp 2012-05-12 17:09:59 UTC (rev 116858)
@@ -722,6 +722,14 @@
return m_fullscreenWebPageClient;
}
+bool MediaPlayerPrivate::isElementPaused() const
+{
+ HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
+ if (!element || element->paused())
+ return true;
+ return false;
+}
+
bool MediaPlayerPrivate::isTabVisible() const
{
if (frameView() && frameView()->hostWindow())
Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h (116857 => 116858)
--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h 2012-05-12 16:35:48 UTC (rev 116857)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h 2012-05-12 17:09:59 UTC (rev 116858)
@@ -132,6 +132,7 @@
#endif
virtual bool isFullscreen() const;
+ virtual bool isElementPaused() const;
virtual bool isTabVisible() const;
virtual int showErrorDialog(BlackBerry::Platform::MMRPlayer::Error);
virtual BlackBerry::Platform::Graphics::Window* platformWindow();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes