Don't pause playback when locking screen if video is being displayed on second screen.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Sep 2018 19:59:33 +0000 (19:59 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Sep 2018 19:59:33 +0000 (19:59 +0000)
commit813fb9bb0a5f5c09645ac3577620d9cf94345db8
tree5ee495faf2dac96560a9bfa4d47c97239e356caf
parent0f56df0be40ee6b84a122b52b29a0dbd87d2a566
Don't pause playback when locking screen if video is being displayed on second screen.
https://bugs.webkit.org/show_bug.cgi?id=189321

Reviewed by Eric Carlson.

Source/WebCore:

Expand the existing behavior when AirPlaying to an external device to playing to a local
external screen. Don't pause when the screen locks, and don't stop buffering in that mode either.

Add a KVO-observer to the WebAVPlayerController's playingOnSecondScreen property, and pass
that observed value on to the media element.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setShouldPlayToPlaybackTarget):
(WebCore::HTMLMediaElement::setPlayingOnSecondScreen):
(WebCore::HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction const):
(WebCore::HTMLMediaElement::processingUserGestureForMedia const):
(WebCore::HTMLMediaElement::mediaState const):
(WebCore::HTMLMediaElement::purgeBufferedDataIfPossible):
(WebCore::HTMLMediaElement::shouldOverrideBackgroundLoadingRestriction const):
(WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless const): Deleted.
(WebCore::HTMLMediaElement::canPlayToWirelessPlaybackTarget const): Deleted.
(WebCore::HTMLMediaElement::isPlayingToWirelessPlaybackTarget const): Deleted.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless const):
(WebCore::HTMLMediaElement::isPlayingToExternalTarget const):
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canPlayToWirelessPlaybackTarget const): Deleted.
* html/MediaElementSession.h:
* platform/audio/PlatformMediaSession.h:
(WebCore::PlatformMediaSessionClient::setWirelessPlaybackTarget):
(WebCore::PlatformMediaSessionClient::isPlayingOnSecondScreen const):
(WebCore::PlatformMediaSession::canPlayToWirelessPlaybackTarget const): Deleted.
(WebCore::PlatformMediaSessionClient::canPlayToWirelessPlaybackTarget const): Deleted.
* platform/cocoa/PlaybackSessionModel.h:
* platform/cocoa/PlaybackSessionModelMediaElement.h:
* platform/cocoa/PlaybackSessionModelMediaElement.mm:
(WebCore::PlaybackSessionModelMediaElement::setPlayingOnSecondScreen):
* platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerController init]):
(-[WebAVPlayerController dealloc]):
(-[WebAVPlayerController observeValueForKeyPath:ofObject:change:context:]):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(VideoFullscreenControllerContext::setPlayingOnSecondScreen):

Source/WebKit:

Pass the "isPlayingOnSecondScreen" value across the process boundary.

* UIProcess/Cocoa/PlaybackSessionManagerProxy.h:
* UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
(WebKit::PlaybackSessionModelContext::setPlayingOnSecondScreen):
(WebKit::PlaybackSessionManagerProxy::setPlayingOnSecondScreen):
* WebProcess/cocoa/PlaybackSessionManager.h:
* WebProcess/cocoa/PlaybackSessionManager.messages.in:
* WebProcess/cocoa/PlaybackSessionManager.mm:
(WebKit::PlaybackSessionManager::setPlayingOnSecondScreen):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235752 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/MediaElementSession.cpp
Source/WebCore/html/MediaElementSession.h
Source/WebCore/platform/audio/PlatformMediaSession.h
Source/WebCore/platform/cocoa/PlaybackSessionModel.h
Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.h
Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.mm
Source/WebCore/platform/ios/WebAVPlayerController.mm
Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h
Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm
Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h
Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.messages.in
Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm