[iOS] Sync media playback with now playing
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Mar 2014 18:24:06 +0000 (18:24 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Mar 2014 18:24:06 +0000 (18:24 +0000)
commit96f47fd060f38d84031a7e107c9c3b2df2eee72a
treeee3748c1b65b4d98bed7dc5e1f4fc83753d3bad1
parent808e0537faf0d6453de7eb47abf5b261dc284af4
[iOS] Sync media playback with now playing
https://bugs.webkit.org/show_bug.cgi?id=130172

Reviewed by Jer Noble.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::play): Move clientWillBeginPlayback to
    playInternal so it is called every time playback begins.
(WebCore::HTMLMediaElement::playInternal): Call clientWillBeginPlayback.
(WebCore::HTMLMediaElement::pause): Move clientWillPausePlayback to
    playInternal so it is called every time playback begins.
(WebCore::HTMLMediaElement::playInternal): Call clientWillPausePlayback.
(WebCore::HTMLMediaElement::mediaSessionTitle): New. Return the 'title' attribute,
    or currenSrc if that is empty.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::mediaSessionDuration): Return duration.
(WebCore::HTMLMediaElement::mediaSessionCurrentTime): Return current time.

* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::clientWillPausePlayback): New, passthrough to the
    media element.
(WebCore::MediaSession::title): Ditto.
(WebCore::MediaSession::duration): Ditto.
(WebCore::MediaSession::currentTime): Ditto.
* platform/audio/MediaSession.h:
(WebCore::MediaSessionClient::mediaSessionTitle):
(WebCore::MediaSessionClient::mediaSessionDuration):
(WebCore::MediaSessionClient::mediaSessionCurrentTime):

* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::MediaSessionManager): Initialize m_activeSession.
(WebCore::MediaSessionManager::removeSession): Set m_activeSession if the session
    being removed is currently active.
(WebCore::MediaSessionManager::sessionWillBeginPlayback): Set m_activeSession.
* platform/audio/MediaSessionManager.h:
(WebCore::MediaSessionManager::sessionWillEndPlayback):
(WebCore::MediaSessionManager::setCurrentSession):
(WebCore::MediaSessionManager::currentSession):

* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::sessionWillBeginPlayback): Call updateNowPlayingInfo.
(WebCore::MediaSessionManageriOS::sessionWillEndPlayback): Ditto.
(WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Update MPNowPlayingInfoCenter
    with the current media item's title, duration, and current time.
(-[WebMediaSessionHelper initWithCallback:]): Turn on deliver of remote control
    events, even though we don't respond to them yet, or Now Playing won't work.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165552 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/audio/MediaSession.cpp
Source/WebCore/platform/audio/MediaSession.h
Source/WebCore/platform/audio/MediaSessionManager.cpp
Source/WebCore/platform/audio/MediaSessionManager.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm