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)
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

index d370a89..3881993 100644 (file)
@@ -1,3 +1,49 @@
+2018-09-06  Jer Noble  <jer.noble@apple.com>
+
+        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.
+
+        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):
+
 2018-09-06  Frederic Wang  <fwang@igalia.com>
 
         Group options of scrollRectToVisible into a struct
index 3019e09..27d4aab 100644 (file)
@@ -5744,11 +5744,6 @@ void HTMLMediaElement::webkitShowPlaybackTargetPicker()
     m_mediaSession->showPlaybackTargetPicker();
 }
 
-bool HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless() const
-{
-    return m_isPlayingToWirelessTarget;
-}
-
 void HTMLMediaElement::wirelessRoutesAvailableDidChange()
 {
     enqueuePlaybackTargetAvailabilityChangedEvent();
@@ -5836,20 +5831,6 @@ void HTMLMediaElement::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& devi
         m_player->setWirelessPlaybackTarget(WTFMove(device));
 }
 
-bool HTMLMediaElement::canPlayToWirelessPlaybackTarget() const
-{
-    bool canPlay = m_player && m_player->canPlayToWirelessPlaybackTarget();
-
-    INFO_LOG(LOGIDENTIFIER, "returning ", canPlay);
-
-    return canPlay;
-}
-
-bool HTMLMediaElement::isPlayingToWirelessPlaybackTarget() const
-{
-    return m_isPlayingToWirelessTarget;
-}
-
 void HTMLMediaElement::setShouldPlayToPlaybackTarget(bool shouldPlay)
 {
     ALWAYS_LOG(LOGIDENTIFIER, shouldPlay);
@@ -5857,14 +5838,20 @@ void HTMLMediaElement::setShouldPlayToPlaybackTarget(bool shouldPlay)
     if (m_player)
         m_player->setShouldPlayToPlaybackTarget(shouldPlay);
 }
-#else // ENABLE(WIRELESS_PLAYBACK_TARGET)
 
-bool HTMLMediaElement::webkitCurrentPlaybackTargetIsWireless() const
+#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)
+
+void HTMLMediaElement::setPlayingOnSecondScreen(bool value)
 {
-    return false;
-}
+    if (value == m_playingOnSecondScreen)
+        return;
 
-#endif // ENABLE(WIRELESS_PLAYBACK_TARGET)
+    m_playingOnSecondScreen = value;
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    updateMediaState(UpdateState::Asynchronously);
+#endif
+}
 
 double HTMLMediaElement::minFastReverseRate() const
 {
@@ -7572,12 +7559,10 @@ bool HTMLMediaElement::supportsSeeking() const
 bool HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType type) const
 {
     if (type == PlatformMediaSession::EnteringBackground) {
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-        if (m_isPlayingToWirelessTarget) {
-            INFO_LOG(LOGIDENTIFIER, "returning true because m_isPlayingToWirelessTarget is true");
+        if (isPlayingToExternalTarget()) {
+            INFO_LOG(LOGIDENTIFIER, "returning true because isPlayingToExternalTarget() is true");
             return true;
         }
-#endif
         if (m_videoFullscreenMode & VideoFullscreenModePictureInPicture)
             return true;
 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
@@ -7585,12 +7570,10 @@ bool HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(PlatformMedia
             return true;
 #endif
     } else if (type == PlatformMediaSession::SuspendedUnderLock) {
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-        if (m_isPlayingToWirelessTarget) {
-            INFO_LOG(LOGIDENTIFIER, "returning true because m_isPlayingToWirelessTarget is true");
+        if (isPlayingToExternalTarget()) {
+            INFO_LOG(LOGIDENTIFIER, "returning true because isPlayingToExternalTarget() is true");
             return true;
         }
-#endif
     }
     return false;
 }
@@ -7599,8 +7582,8 @@ bool HTMLMediaElement::processingUserGestureForMedia() const
 {
     return document().processingUserGestureForMedia();
 }
-
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
+
 void HTMLMediaElement::updateMediaState(UpdateState updateState)
 {
     if (updateState == UpdateState::Asynchronously) {
@@ -7628,10 +7611,10 @@ MediaProducer::MediaStateFlags HTMLMediaElement::mediaState() const
 
     bool hasActiveVideo = isVideo() && hasVideo();
     bool hasAudio = this->hasAudio();
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    if (m_isPlayingToWirelessTarget)
+    if (isPlayingToExternalTarget())
         state |= IsPlayingToExternalDevice;
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
     if (m_hasPlaybackTargetAvailabilityListeners) {
         state |= HasPlaybackTargetAvailabilityListener;
         if (!m_mediaSession->wirelessVideoPlaybackDisabled())
@@ -7754,7 +7737,7 @@ void HTMLMediaElement::purgeBufferedDataIfPossible()
     if (!MemoryPressureHandler::singleton().isUnderMemoryPressure() && m_mediaSession->dataBufferingPermitted())
         return;
 
-    if (m_isPlayingToWirelessTarget) {
+    if (isPlayingToExternalTarget()) {
         INFO_LOG(LOGIDENTIFIER, "early return because playing to wireless target");
         return;
     }
@@ -7933,10 +7916,8 @@ void HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired()
 
 bool HTMLMediaElement::shouldOverrideBackgroundLoadingRestriction() const
 {
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-    if (isPlayingToWirelessPlaybackTarget())
+    if (isPlayingToExternalTarget())
         return true;
-#endif
 
     return m_videoFullscreenMode == VideoFullscreenModePictureInPicture;
 }
index a78ecfd..572c189 100644 (file)
@@ -404,12 +404,16 @@ public:
     bool removeEventListener(const AtomicString& eventType, EventListener&, const ListenerOptions&) override;
 
     void wirelessRoutesAvailableDidChange() override;
-    bool canPlayToWirelessPlaybackTarget() const override;
-    bool isPlayingToWirelessPlaybackTarget() const override;
     void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&) override;
     void setShouldPlayToPlaybackTarget(bool) override;
 #endif
-    bool webkitCurrentPlaybackTargetIsWireless() const;
+    bool isPlayingToWirelessPlaybackTarget() const override { return m_isPlayingToWirelessTarget; };
+    bool webkitCurrentPlaybackTargetIsWireless() const { return m_isPlayingToWirelessTarget; }
+
+    void setPlayingOnSecondScreen(bool value);
+    bool isPlayingOnSecondScreen() const override { return m_playingOnSecondScreen; }
+
+    bool isPlayingToExternalTarget() const { return isPlayingToWirelessPlaybackTarget() || isPlayingOnSecondScreen(); }
 
     // EventTarget function.
     // Both Node (via HTMLElement) and ActiveDOMObject define this method, which
@@ -1170,8 +1174,10 @@ private:
     MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
     bool m_hasPlaybackTargetAvailabilityListeners { false };
     bool m_failedToPlayToWirelessTarget { false };
-    bool m_isPlayingToWirelessTarget { false };
 #endif
+
+    bool m_isPlayingToWirelessTarget { false };
+    bool m_playingOnSecondScreen { false };
 };
 
 String convertEnumerationToString(HTMLMediaElement::PlaybackWithoutUserGesture);
index 82f3c76..dc7d5c1 100644 (file)
@@ -651,16 +651,6 @@ void MediaElementSession::externalOutputDeviceAvailableDidChange(bool hasTargets
     m_targetAvailabilityChangedTimer.startOneShot(0_s);
 }
 
-bool MediaElementSession::canPlayToWirelessPlaybackTarget() const
-{
-#if !PLATFORM(IOS)
-    if (!m_playbackTarget || !m_playbackTarget->hasActiveRoute())
-        return false;
-#endif
-
-    return client().canPlayToWirelessPlaybackTarget();
-}
-
 bool MediaElementSession::isPlayingToWirelessPlaybackTarget() const
 {
 #if !PLATFORM(IOS)
index ffed5b3..6d6ecf7 100644 (file)
@@ -87,7 +87,6 @@ public:
 
     void setHasPlaybackTargetAvailabilityListeners(bool);
 
-    bool canPlayToWirelessPlaybackTarget() const override;
     bool isPlayingToWirelessPlaybackTarget() const override;
 
     void mediaStateDidChange(MediaProducer::MediaStateFlags);
index 11f7aac..a3ecf01 100644 (file)
@@ -152,7 +152,6 @@ public:
 
     bool shouldOverrideBackgroundLoadingRestriction() const;
 
-    virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
     virtual bool isPlayingToWirelessPlaybackTarget() const { return m_isPlayingToWirelessPlaybackTarget; }
     void isPlayingToWirelessPlaybackTargetChanged(bool);
 
@@ -240,10 +239,11 @@ public:
 
     virtual void wirelessRoutesAvailableDidChange() { }
     virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&) { }
-    virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
     virtual bool isPlayingToWirelessPlaybackTarget() const { return false; }
     virtual void setShouldPlayToPlaybackTarget(bool) { }
 
+    virtual bool isPlayingOnSecondScreen() const { return false; }
+
     virtual Document* hostingDocument() const = 0;
     virtual String sourceApplicationIdentifier() const = 0;
 
index 1c4f0e3..eff018e 100644 (file)
@@ -59,6 +59,7 @@ public:
     virtual void toggleMuted() = 0;
     virtual void setMuted(bool) = 0;
     virtual void setVolume(double) = 0;
+    virtual void setPlayingOnSecondScreen(bool) = 0;
 
     enum ExternalPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut };
 
index f5927dc..f7420b3 100644 (file)
@@ -73,6 +73,7 @@ public:
     WEBCORE_EXPORT void toggleMuted() final;
     WEBCORE_EXPORT void setMuted(bool) final;
     WEBCORE_EXPORT void setVolume(double) final;
+    WEBCORE_EXPORT void setPlayingOnSecondScreen(bool) final;
 
     double duration() const final;
     double currentTime() const final;
index a11b70c..a190d68 100644 (file)
@@ -325,6 +325,12 @@ void PlaybackSessionModelMediaElement::setVolume(double volume)
         m_mediaElement->setVolume(volume);
 }
 
+void PlaybackSessionModelMediaElement::setPlayingOnSecondScreen(bool value)
+{
+    if (m_mediaElement)
+        m_mediaElement->setPlayingOnSecondScreen(value);
+}
+
 void PlaybackSessionModelMediaElement::updateMediaSelectionOptions()
 {
     if (!m_mediaElement)
index 8481423..3721800 100644 (file)
@@ -48,6 +48,7 @@ using namespace WebCore;
 
 static void * WebAVPlayerControllerSeekableTimeRangesObserverContext = &WebAVPlayerControllerSeekableTimeRangesObserverContext;
 static void * WebAVPlayerControllerHasLiveStreamingContentObserverContext = &WebAVPlayerControllerHasLiveStreamingContentObserverContext;
+static void * WebAVPlayerControllerIsPlayingOnSecondScreenObserverContext = &WebAVPlayerControllerIsPlayingOnSecondScreenObserverContext;
 
 static double WebAVPlayerControllerLiveStreamSeekableTimeRangeDurationHysteresisDelta = 3.0; // Minimum delta of time required to change the duration of the seekable time range.
 static double WebAVPlayerControllerLiveStreamMinimumTargetDuration = 1.0; // Minimum segment duration to be considered valid.
@@ -71,7 +72,7 @@ static double WebAVPlayerControllerLiveStreamSeekableTimeRangeMinimumDuration =
 
     [self addObserver:self forKeyPath:@"seekableTimeRanges" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial) context:WebAVPlayerControllerSeekableTimeRangesObserverContext];
     [self addObserver:self forKeyPath:@"hasLiveStreamingContent" options:NSKeyValueObservingOptionInitial context:WebAVPlayerControllerHasLiveStreamingContentObserverContext];
-
+    [self addObserver:self forKeyPath:@"playingOnSecondScreen" options:NSKeyValueObservingOptionNew context:WebAVPlayerControllerIsPlayingOnSecondScreenObserverContext];
 
     return self;
 }
@@ -80,6 +81,7 @@ static double WebAVPlayerControllerLiveStreamSeekableTimeRangeMinimumDuration =
 {
     [self removeObserver:self forKeyPath:@"seekableTimeRanges" context:WebAVPlayerControllerSeekableTimeRangesObserverContext];
     [self removeObserver:self forKeyPath:@"hasLiveStreamingContent" context:WebAVPlayerControllerHasLiveStreamingContentObserverContext];
+    [self removeObserver:self forKeyPath:@"playingOnSecondScreen" context:WebAVPlayerControllerIsPlayingOnSecondScreenObserverContext];
 
     [_playerControllerProxy release];
     [_loadedTimeRanges release];
@@ -553,6 +555,10 @@ static double WebAVPlayerControllerLiveStreamSeekableTimeRangeMinimumDuration =
         }
     } else if (WebAVPlayerControllerHasLiveStreamingContentObserverContext == context)
         [self updateMinMaxTiming];
+    else if (WebAVPlayerControllerIsPlayingOnSecondScreenObserverContext == context) {
+        if (auto* delegate = self.delegate)
+            delegate->setPlayingOnSecondScreen(_playingOnSecondScreen);
+    }
 }
 
 - (void)updateMinMaxTiming
index 7ff0cf5..32a1e72 100644 (file)
@@ -174,6 +174,7 @@ private:
     void toggleMuted() override;
     void setMuted(bool) final;
     void setVolume(double) final;
+    void setPlayingOnSecondScreen(bool) final;
 
     // PlaybackSessionModelClient
     void durationChanged(double) override;
@@ -742,6 +743,15 @@ void VideoFullscreenControllerContext::setVolume(double volume)
     });
 }
 
+void VideoFullscreenControllerContext::setPlayingOnSecondScreen(bool value)
+{
+    ASSERT(isUIThread());
+    WebThreadRun([protectedThis = makeRefPtr(this), this, value] {
+        if (m_playbackModel)
+            m_playbackModel->setPlayingOnSecondScreen(value);
+    });
+}
+
 void VideoFullscreenControllerContext::beginScrubbing()
 {
     ASSERT(isUIThread());
index ff354b0..989f322 100644 (file)
@@ -1,3 +1,21 @@
+2018-09-06  Jer Noble  <jer.noble@apple.com>
+
+        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.
+
+        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):
+
 2018-09-06  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [macOS] Cannot change font size at selection until font panel is shown
index 835bb9b..68a88b5 100644 (file)
@@ -113,6 +113,7 @@ private:
     void toggleMuted() final;
     void setMuted(bool) final;
     void setVolume(double) final;
+    void setPlayingOnSecondScreen(bool) final;
 
     double playbackStartedTime() const final { return m_playbackStartedTime; }
     double duration() const final { return m_duration; }
@@ -231,6 +232,7 @@ private:
     void toggleMuted(uint64_t contextId);
     void setMuted(uint64_t contextId, bool);
     void setVolume(uint64_t contextId, double);
+    void setPlayingOnSecondScreen(uint64_t contextId, bool);
 
     WebPageProxy* m_page;
     HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
index c0b80ff..6304be7 100644 (file)
@@ -151,6 +151,12 @@ void PlaybackSessionModelContext::setVolume(double volume)
         m_manager->setVolume(m_contextId, volume);
 }
 
+void PlaybackSessionModelContext::setPlayingOnSecondScreen(bool value)
+{
+    if (m_manager)
+        m_manager->setPlayingOnSecondScreen(m_contextId, value);
+}
+
 void PlaybackSessionModelContext::playbackStartedTimeChanged(double playbackStartedTime)
 {
     m_playbackStartedTime = playbackStartedTime;
@@ -571,6 +577,12 @@ void PlaybackSessionManagerProxy::setVolume(uint64_t contextId, double volume)
     m_page->send(Messages::PlaybackSessionManager::SetVolume(contextId, volume), m_page->pageID());
 }
 
+void PlaybackSessionManagerProxy::setPlayingOnSecondScreen(uint64_t contextId, bool value)
+{
+    if (m_page)
+        m_page->send(Messages::PlaybackSessionManager::SetPlayingOnSecondScreen(contextId, value), m_page->pageID());
+}
+
 void PlaybackSessionManagerProxy::requestControlledElementID()
 {
     if (m_controlsManagerContextId)
index d297dac..1a85762 100644 (file)
@@ -162,6 +162,7 @@ protected:
     void toggleMuted(uint64_t contextId);
     void setMuted(uint64_t contextId, bool muted);
     void setVolume(uint64_t contextId, double volume);
+    void setPlayingOnSecondScreen(uint64_t contextId, bool value);
 
     WebPage* m_page;
     HashMap<WebCore::HTMLMediaElement*, uint64_t> m_mediaElements;
index 4d2a786..453008d 100644 (file)
@@ -40,5 +40,6 @@ messages -> PlaybackSessionManager {
     ToggleMuted(uint64_t contextId)
     SetMuted(uint64_t contextId, bool muted)
     SetVolume(uint64_t contextId, double volume)
+    SetPlayingOnSecondScreen(uint64_t contextId, bool value)
 }
 #endif
index c03bf57..088494b 100644 (file)
@@ -507,6 +507,12 @@ void PlaybackSessionManager::setVolume(uint64_t contextId, double volume)
     ensureModel(contextId).setVolume(volume);
 }
 
+void PlaybackSessionManager::setPlayingOnSecondScreen(uint64_t contextId, bool value)
+{
+    UserGestureIndicator indicator(ProcessingUserGesture);
+    ensureModel(contextId).setPlayingOnSecondScreen(value);
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))