[Mac] Register with device picker whenever a page has <video>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2015 23:03:40 +0000 (23:03 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2015 23:03:40 +0000 (23:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144408

Reviewed by Jer Noble.

* Modules/mediasession/WebMediaSessionManager.cpp:
(WebCore::WebMediaSessionManager::setPlaybackTarget): Drive-by fix: don't tell a client to play
to the target when it has not routes.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaState): Set RequiresPlaybackTargetMonitoring whenever the
element is <video> with a video track that does not block wireless playback.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183587 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasession/WebMediaSessionManager.cpp
Source/WebCore/html/HTMLMediaElement.cpp

index 440ab1f..8092430 100644 (file)
@@ -1,3 +1,18 @@
+2015-04-29  Eric Carlson  <eric.carlson@apple.com>
+
+        [Mac] Register with device picker whenever a page has <video>
+        https://bugs.webkit.org/show_bug.cgi?id=144408
+
+        Reviewed by Jer Noble.
+
+        * Modules/mediasession/WebMediaSessionManager.cpp:
+        (WebCore::WebMediaSessionManager::setPlaybackTarget): Drive-by fix: don't tell a client to play
+        to the target when it has not routes.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaState): Set RequiresPlaybackTargetMonitoring whenever the 
+        element is <video> with a video track that does not block wireless playback.
+
 2015-04-29  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] Add support for automatic hyphenation
index b1ee3f4..b1acfe1 100644 (file)
@@ -191,7 +191,7 @@ void WebMediaSessionManager::setPlaybackTarget(Ref<MediaPlaybackTarget>&& target
         return;
 
     auto& state = m_clientState[indexThatRequestedPicker];
-    state->client->setShouldPlayToPlaybackTarget(state->contextId, true);
+    state->client->setShouldPlayToPlaybackTarget(state->contextId, m_playbackTarget && m_playbackTarget->hasActiveRoute());
     state->requestedPicker = false;
 }
 
index 24183c1..793bfbd 100644 (file)
@@ -6188,12 +6188,15 @@ MediaProducer::MediaStateFlags HTMLMediaElement::mediaState() const
 
     MediaStateFlags state = IsNotPlaying;
 
+    bool hasActiveVideo = isVideo() && hasVideo();
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     if (isPlayingToWirelessPlaybackTarget())
         state |= IsPlayingToExternalDevice;
 
-    if (m_hasPlaybackTargetAvailabilityListeners)
-        state |= RequiresPlaybackTargetMonitoring;
+    if (!m_mediaSession->wirelessVideoPlaybackDisabled(*this)) {
+        if ((m_hasPlaybackTargetAvailabilityListeners || hasActiveVideo) && m_player->canPlayToWirelessPlaybackTarget())
+            state |= RequiresPlaybackTargetMonitoring;
+    }
 #endif
 
     if (!isPlaying())
@@ -6202,7 +6205,7 @@ MediaProducer::MediaStateFlags HTMLMediaElement::mediaState() const
     if (hasAudio() && !muted())
         state |= IsPlayingAudio;
 
-    if (hasVideo())
+    if (hasActiveVideo)
         state |= IsPlayingVideo;
 
     return state;