[webkit-changes] [WebKit/WebKit] f89ad9: Add basic support to play or pause media playback ...

Wenson Hsieh noreply at github.com
Fri Jul 5 07:48:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f89ad9045bd3cacee1f67b30d07a8420fb563be1
      https://github.com/WebKit/WebKit/commit/f89ad9045bd3cacee1f67b30d07a8420fb563be1
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-07-05 (Fri, 05 Jul 2024)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
    M Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm

  Log Message:
  -----------
  Add basic support to play or pause media playback for active (Now Playing) media
https://bugs.webkit.org/show_bug.cgi?id=276235
rdar://131137466

Reviewed by Eric Carlson.

Add support for `-_playPredominantOrNowPlayingMediaSession:` and `-_pauseNowPlayingMediaSession:`.
See comments below.

* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _playPredominantOrNowPlayingMediaSession:]):
(-[WKWebView _pauseNowPlayingMediaSession:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::playPredominantOrNowPlayingMediaSession):

Add plumbing to get to the playback session model of the active playback session. Note that these
currently take completion handlers (despite being synchronous), since the next patch will add a
heuristic to asynchronously find and play the most prominent video element in the viewport as a
fallback, in the case where there's no current media session.

(WebKit::WebPageProxy::pauseNowPlayingMediaSession):
(WebKit::WebPageProxy::tryToSendCommandToActiveControlledVideo):

Add a helper method to send a `RemoteControlCommandType` to the current playback session model.

* Source/WebKit/UIProcess/WebPageProxy.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm:
(-[VideoControlsManagerTestWebView _playPredominantOrNowPlayingMediaSession]):
(-[VideoControlsManagerTestWebView _pauseNowPlayingMediaSession]):
(-[VideoControlsManagerTestWebView waitForVideoToPlay]):
(-[VideoControlsManagerTestWebView waitForVideoToPause]):
(TestWebKitAPI::TEST(VideoControlsManager, TogglePlaybackForControlledVideo)):

Add an API test that exercises the new `WKWebView` methods.

Canonical link: https://commits.webkit.org/280686@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list