Title: [264638] trunk/Source/WebCore
Revision
264638
Author
[email protected]
Date
2020-07-20 16:54:06 -0700 (Mon, 20 Jul 2020)

Log Message

An airplaying video can enter picture-in-picture
https://bugs.webkit.org/show_bug.cgi?id=214556

Reviewed by Eric Carlson.

WebAVPlayerController replaces the AVPlayerController used by AVKit. Its property
"pictureInPicturePossible" will always be YES after VideoFullscreenInterfaceAVKit::doSetup()
sets it, even after the video enters picture-in-picture.

This patch fixes the issue by checking whether the video is airplaying (isExternalPlaybackActive)
in -[WebAVPlayerController isPictureInPicturePossible].

AVPlayerController has the logic to change the property "pictureInPicturePossible" to NO
after a video enters picture-in-picture, but we cannot use AVPlayerController's value of
"pictureInPicturePossible" as the property value of WebAVPlayerController. Because the value of
"-[AVPlayerController isPictureInPicturePossible]" depends on the value of
"[[AVAudioSession sharedInstance] isPiPAvailable]", which is always NO in the UI process.
(AVAudioSession related code is in the web process).

* platform/ios/VideoFullscreenInterfaceAVKit.mm:
(VideoFullscreenInterfaceAVKit::doSetup):
* platform/ios/WebAVPlayerController.h:
* platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerController setAllowsPictureInPicture:]):
(-[WebAVPlayerController isPictureInPicturePossible]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (264637 => 264638)


--- trunk/Source/WebCore/ChangeLog	2020-07-20 23:48:39 UTC (rev 264637)
+++ trunk/Source/WebCore/ChangeLog	2020-07-20 23:54:06 UTC (rev 264638)
@@ -1,3 +1,31 @@
+2020-07-20  Peng Liu  <[email protected]>
+
+        An airplaying video can enter picture-in-picture
+        https://bugs.webkit.org/show_bug.cgi?id=214556
+
+        Reviewed by Eric Carlson.
+
+        WebAVPlayerController replaces the AVPlayerController used by AVKit. Its property
+        "pictureInPicturePossible" will always be YES after VideoFullscreenInterfaceAVKit::doSetup()
+        sets it, even after the video enters picture-in-picture.
+
+        This patch fixes the issue by checking whether the video is airplaying (isExternalPlaybackActive)
+        in -[WebAVPlayerController isPictureInPicturePossible].
+
+        AVPlayerController has the logic to change the property "pictureInPicturePossible" to NO
+        after a video enters picture-in-picture, but we cannot use AVPlayerController's value of
+        "pictureInPicturePossible" as the property value of WebAVPlayerController. Because the value of
+        "-[AVPlayerController isPictureInPicturePossible]" depends on the value of
+        "[[AVAudioSession sharedInstance] isPiPAvailable]", which is always NO in the UI process.
+        (AVAudioSession related code is in the web process).
+
+        * platform/ios/VideoFullscreenInterfaceAVKit.mm:
+        (VideoFullscreenInterfaceAVKit::doSetup):
+        * platform/ios/WebAVPlayerController.h:
+        * platform/ios/WebAVPlayerController.mm:
+        (-[WebAVPlayerController setAllowsPictureInPicture:]):
+        (-[WebAVPlayerController isPictureInPicturePossible]):
+
 2020-07-20  Megan Gardner  <[email protected]>
 
         Add OK button to Date/Time form controls.

Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (264637 => 264638)


--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2020-07-20 23:48:39 UTC (rev 264637)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2020-07-20 23:54:06 UTC (rev 264638)
@@ -1343,7 +1343,7 @@
     [m_playerViewController setPlayerController:(AVPlayerController *)playerController()];
     [m_playerViewController setDelegate:m_playerViewControllerDelegate.get()];
     [m_playerViewController setAllowsPictureInPicturePlayback:m_allowsPictureInPicturePlayback];
-    [playerController() setPictureInPicturePossible:m_allowsPictureInPicturePlayback];
+    [playerController() setAllowsPictureInPicture:m_allowsPictureInPicturePlayback];
     if (!m_routingContextUID.isEmpty())
         [m_playerViewController setWebKitOverrideRouteSharingPolicy:(NSUInteger)m_routeSharingPolicy routingContextUID:m_routingContextUID];
 

Modified: trunk/Source/WebCore/platform/ios/WebAVPlayerController.h (264637 => 264638)


--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.h	2020-07-20 23:48:39 UTC (rev 264637)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.h	2020-07-20 23:54:06 UTC (rev 264638)
@@ -43,6 +43,8 @@
     BOOL _muted;
 }
 
+- (void)setAllowsPictureInPicture:(BOOL)allowsPictureInPicture;
+
 @property (retain) AVPlayerController* playerControllerProxy;
 @property (assign) WebCore::PlaybackSessionModel* delegate;
 @property (assign) WebCore::PlaybackSessionInterfaceAVKit* playbackSessionInterface;
@@ -92,7 +94,7 @@
 @property AVPlayerControllerExternalPlaybackType externalPlaybackType;
 @property (retain) NSString *externalPlaybackAirPlayDeviceLocalizedName;
 @property BOOL allowsExternalPlayback;
-@property (getter=isPictureInPicturePossible) BOOL pictureInPicturePossible;
+@property (readonly, getter=isPictureInPicturePossible) BOOL pictureInPicturePossible;
 @property (getter=isPictureInPictureInterrupted) BOOL pictureInPictureInterrupted;
 
 @property NSTimeInterval seekableTimeRangesLastModifiedTime;

Modified: trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm (264637 => 264638)


--- trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm	2020-07-20 23:48:39 UTC (rev 264637)
+++ trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm	2020-07-20 23:54:06 UTC (rev 264638)
@@ -57,6 +57,7 @@
 @implementation WebAVPlayerController {
     BOOL _liveStreamEventModePossible;
     BOOL _isScrubbing;
+    BOOL _allowsPictureInPicture;
 }
 
 - (instancetype)init
@@ -502,6 +503,16 @@
     return [NSSet setWithObjects:@"externalPlaybackActive", @"playingOnSecondScreen", nil];
 }
 
+- (void)setAllowsPictureInPicture:(BOOL)allowsPictureInPicture
+{
+    _allowsPictureInPicture = allowsPictureInPicture;
+}
+
+- (BOOL)isPictureInPicturePossible
+{
+    return _allowsPictureInPicture && ![self isExternalPlaybackActive];
+}
+
 - (BOOL)isPictureInPictureInterrupted
 {
     return _pictureInPictureInterrupted;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to