Allow media engine to update HTMLMediaElement state when playing to external device
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Mar 2014 22:42:40 +0000 (22:42 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Mar 2014 22:42:40 +0000 (22:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130480

Reviewed by Jer Noble.

* html/HTMLMediaElement.h: Add mediaPlayerHandlePlaybackCommand.

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::handlePlaybackCommand): New.
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerHandlePlaybackCommand):

* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::rateChanged): Send Play and Pause commands when
    playing to an external device.

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

index edc868e..00cf7ff 100644 (file)
@@ -1,3 +1,21 @@
+2014-03-19  Eric Carlson  <eric.carlson@apple.com>
+
+        Allow media engine to update HTMLMediaElement state when playing to external device
+        https://bugs.webkit.org/show_bug.cgi?id=130480
+
+        Reviewed by Jer Noble.
+
+        * html/HTMLMediaElement.h: Add mediaPlayerHandlePlaybackCommand.
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::handlePlaybackCommand): New.
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerHandlePlaybackCommand):
+
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::rateChanged): Send Play and Pause commands when
+            playing to an external device.
+
 2014-03-19  Dirk Schulze  <krit@webkit.org>
 
         Implement isPointInPath and isPointInStroke with Path2D argument
index a74ad16..3858d46 100644 (file)
@@ -585,6 +585,7 @@ private:
 #endif
 
     virtual bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) override;
+    virtual void mediaPlayerHandlePlaybackCommand(MediaSession::RemoteControlCommandType command) override { didReceiveRemoteControlCommand(command); }
 
     void loadTimerFired(Timer<HTMLMediaElement>&);
     void progressEventTimerFired(Timer<HTMLMediaElement>&);
index 401d075..9d0f012 100644 (file)
@@ -1398,6 +1398,14 @@ bool MediaPlayer::shouldWaitForResponseToAuthenticationChallenge(const Authentic
 
     return m_mediaPlayerClient->mediaPlayerShouldWaitForResponseToAuthenticationChallenge(challenge);
 }
+    
+void MediaPlayer::handlePlaybackCommand(MediaSession::RemoteControlCommandType command)
+{
+    if (!m_mediaPlayerClient)
+        return;
+    
+    m_mediaPlayerClient->mediaPlayerHandlePlaybackCommand(command);
+}
 
 void MediaPlayerFactorySupport::callRegisterMediaEngine(MediaEngineRegister registerMediaEngine)
 {
index 5911d82..bd61370 100644 (file)
@@ -38,6 +38,7 @@
 #include "IntRect.h"
 #include "URL.h"
 #include "LayoutRect.h"
+#include "MediaSession.h"
 #include "NativeImagePtr.h"
 #include "PlatformLayer.h"
 #include "Timer.h"
@@ -264,6 +265,7 @@ public:
 #endif
 
     virtual bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) { return false; }
+    virtual void mediaPlayerHandlePlaybackCommand(MediaSession::RemoteControlCommandType) { }
 };
 
 class MediaPlayerSupportsTypeClient {
@@ -573,6 +575,7 @@ public:
 #endif
 
     bool shouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&);
+    void handlePlaybackCommand(MediaSession::RemoteControlCommandType);
 
 private:
     MediaPlayer(MediaPlayerClient*);
index f7b439d..b6ad1e1 100644 (file)
@@ -616,6 +616,11 @@ void MediaPlayerPrivateAVFoundation::metadataLoaded()
 
 void MediaPlayerPrivateAVFoundation::rateChanged()
 {
+#if ENABLE(IOS_AIRPLAY)
+    if (isCurrentPlaybackTargetWireless())
+        m_player->handlePlaybackCommand(rate() ? MediaSession::PlayCommand : MediaSession::PauseCommand);
+#endif
+
     m_player->rateChanged();
 }