Title: [280330] trunk
Revision
280330
Author
[email protected]
Date
2021-07-26 17:25:42 -0700 (Mon, 26 Jul 2021)

Log Message

Video pauses after scrubbing with Touch Bar
https://bugs.webkit.org/show_bug.cgi?id=228277
rdar://80606886

Reviewed by Jer Noble.

Source/WebCore:

In https://trac.webkit.org/r206487 ; in order to ensure that the playback state
was properly reflected following a seek using the touch bar, the element was paused.
It's unclear if that workaround is still required, but for now we will record if the
element was playing before the seek and if so, resume playback once the seek completes.
Now that the touch bar and Now Playing are hooked to the Media Session action handlers
the behaviour change will occur for all those components.

Test: media/media-session/play-after-seek.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Initialize new member in constructor.
(WebCore::HTMLMediaElement::clearSeeking):
(WebCore::HTMLMediaElement::finishSeek): Call play() once seek completes if the element
was playing before.
(WebCore::HTMLMediaElement::pause): Ensure that if pause() is called before the seek
completes, the element stays paused.
(WebCore::HTMLMediaElement::handleSeekToPlaybackPosition): Record playing state before
pausing the element.
* html/HTMLMediaElement.h: Add new boolean member.

LayoutTests:

* media/media-session/play-after-seek-expected.txt: Added.
* media/media-session/play-after-seek.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280329 => 280330)


--- trunk/LayoutTests/ChangeLog	2021-07-27 00:15:05 UTC (rev 280329)
+++ trunk/LayoutTests/ChangeLog	2021-07-27 00:25:42 UTC (rev 280330)
@@ -1,3 +1,14 @@
+2021-07-26  Jean-Yves Avenard  <[email protected]>
+
+        Video pauses after scrubbing with Touch Bar
+        https://bugs.webkit.org/show_bug.cgi?id=228277
+        rdar://80606886
+
+        Reviewed by Jer Noble.
+
+        * media/media-session/play-after-seek-expected.txt: Added.
+        * media/media-session/play-after-seek.html: Added.
+
 2021-07-26  Eric Hutchison  <[email protected]>
 
         Update test expectations for inspector/canvas/recording-bitmaprenderer-memoryLimit.html.

Added: trunk/LayoutTests/media/media-session/play-after-seek-expected.txt (0 => 280330)


--- trunk/LayoutTests/media/media-session/play-after-seek-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-session/play-after-seek-expected.txt	2021-07-27 00:25:42 UTC (rev 280330)
@@ -0,0 +1,22 @@
+
+RUN(video.src = "" "../content/test"))
+EVENT(loadeddata)
+Test that playback will resume following a seek through media session.
+RUN(video.play())
+RUN(internals.sendMediaSessionAction(navigator.mediaSession, {action: "seekto", seekTime: 1}))
+EXPECTED (video.currentTime == '1') OK
+EVENT(seeked)
+EXPECTED (video.paused == 'false') OK
+Test that playback will stay paused if pause() got called before seek completed.
+RUN(internals.sendMediaSessionAction(navigator.mediaSession, {action: "seekto", seekTime: 1}))
+EXPECTED (video.currentTime == '1') OK
+RUN(video.pause())
+EVENT(seeked)
+EXPECTED (video.paused == 'true') OK
+Test that playback will stay paused after a seek.
+RUN(internals.sendMediaSessionAction(navigator.mediaSession, {action: "seekto", seekTime: 1}))
+EXPECTED (video.currentTime == '1') OK
+EVENT(seeked)
+EXPECTED (video.paused == 'true') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/media-session/play-after-seek.html (0 => 280330)


--- trunk/LayoutTests/media/media-session/play-after-seek.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-session/play-after-seek.html	2021-07-27 00:25:42 UTC (rev 280330)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>default-actionHandlers</title>
+    <script src=""
+    <script src=""
+    <script>
+
+    async function runTest() {
+        if (!window.internals) {
+            failTest('This test requires Internals');
+            return;
+        }
+
+        findMediaElement();
+        run('video.src = "" "../content/test")');
+        await waitFor(video, 'loadeddata');
+
+        consoleWrite('Test that playback will resume following a seek through media session.');
+
+        run("video.play()");
+
+        run('internals.sendMediaSessionAction(navigator.mediaSession, {action: "seekto", seekTime: 1})');
+        testExpected("video.currentTime", 1);
+        await waitFor(video, 'seeked');
+        testExpected("video.paused", false);
+
+        consoleWrite('Test that playback will stay paused if pause() got called before seek completed.');
+
+        run('internals.sendMediaSessionAction(navigator.mediaSession, {action: "seekto", seekTime: 1})');
+        testExpected("video.currentTime", 1);
+        run("video.pause()");
+        await waitFor(video, 'seeked');
+        testExpected("video.paused", true);
+
+        consoleWrite('Test that playback will stay paused after a seek.');
+
+        run('internals.sendMediaSessionAction(navigator.mediaSession, {action: "seekto", seekTime: 1})');
+        testExpected("video.currentTime", 1);
+        await waitFor(video, 'seeked');
+        testExpected("video.paused", true);
+
+        endTest();
+    }
+    </script>
+</head>
+<body _onload_="runTest()">
+    <video controls preload='auto'></video>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (280329 => 280330)


--- trunk/Source/WebCore/ChangeLog	2021-07-27 00:15:05 UTC (rev 280329)
+++ trunk/Source/WebCore/ChangeLog	2021-07-27 00:25:42 UTC (rev 280330)
@@ -1,3 +1,31 @@
+2021-07-26  Jean-Yves Avenard  <[email protected]>
+
+        Video pauses after scrubbing with Touch Bar
+        https://bugs.webkit.org/show_bug.cgi?id=228277
+        rdar://80606886
+
+        Reviewed by Jer Noble.
+
+        In https://trac.webkit.org/r206487 ; in order to ensure that the playback state
+        was properly reflected following a seek using the touch bar, the element was paused.
+        It's unclear if that workaround is still required, but for now we will record if the
+        element was playing before the seek and if so, resume playback once the seek completes.
+        Now that the touch bar and Now Playing are hooked to the Media Session action handlers
+        the behaviour change will occur for all those components.
+
+        Test: media/media-session/play-after-seek.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement): Initialize new member in constructor.
+        (WebCore::HTMLMediaElement::clearSeeking):
+        (WebCore::HTMLMediaElement::finishSeek): Call play() once seek completes if the element
+        was playing before.
+        (WebCore::HTMLMediaElement::pause): Ensure that if pause() is called before the seek
+        completes, the element stays paused.
+        (WebCore::HTMLMediaElement::handleSeekToPlaybackPosition): Record playing state before
+        pausing the element.
+        * html/HTMLMediaElement.h: Add new boolean member.
+
 2021-07-26  Ryosuke Niwa  <[email protected]>
 
         Deploy smart pointers in ApplyBlockElementCommand, IndentOutdentCommand and InsertListCommand

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (280329 => 280330)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-07-27 00:15:05 UTC (rev 280329)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2021-07-27 00:25:42 UTC (rev 280330)
@@ -414,6 +414,7 @@
     , m_paused(true)
     , m_seeking(false)
     , m_seekRequested(false)
+    , m_wasPlayingBeforeSeeking(false)
     , m_sentStalledEvent(false)
     , m_sentEndEvent(false)
     , m_pausedInternal(false)
@@ -3081,11 +3082,13 @@
     m_seeking = false;
     m_seekRequested = false;
     m_pendingSeekType = NoSeek;
+    m_wasPlayingBeforeSeeking = false;
     invalidateCachedTime();
 }
 
 void HTMLMediaElement::finishSeek()
 {
+    bool wasPlayingBeforeSeeking = m_wasPlayingBeforeSeeking;
     // 4.8.10.9 Seeking
     // 14 - Set the seeking IDL attribute to false.
     clearSeeking();
@@ -3111,6 +3114,8 @@
     if (m_mediaSource)
         m_mediaSource->monitorSourceBuffers();
 #endif
+    if (wasPlayingBeforeSeeking)
+        playInternal();
 }
 
 HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const
@@ -3565,6 +3570,8 @@
         removeBehaviorRestrictionsAfterFirstUserGesture(MediaElementSession::RequireUserGestureToControlControlsManager);
 
     pauseInternal();
+    // If we have a pending seek, ensure playback doesn't resume.
+    m_wasPlayingBeforeSeeking = false;
 }
 
 void HTMLMediaElement::pauseInternal()
@@ -4854,7 +4861,7 @@
 
     if (!m_isScrubbingRemotely) {
         m_isScrubbingRemotely = true;
-        if (!paused())
+        if ((m_wasPlayingBeforeSeeking = !paused()))
             pauseInternal();
     }
 #else

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (280329 => 280330)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2021-07-27 00:15:05 UTC (rev 280329)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2021-07-27 00:25:42 UTC (rev 280330)
@@ -1071,6 +1071,7 @@
     bool m_paused : 1;
     bool m_seeking : 1;
     bool m_seekRequested : 1;
+    bool m_wasPlayingBeforeSeeking : 1;
 
     // data has not been loaded since sending a "stalled" event
     bool m_sentStalledEvent : 1;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to