https://bugs.webkit.org/show_bug.cgi?id=145829
Patch by Matt Rajca <mrajca@apple.com> on 2015-06-10
Reviewed by Eric Carlson.
* Modules/mediasession/MediaSession.cpp: Add support for keeping track of active media elements.
(WebCore::MediaSession::addActiveMediaElement):
* Modules/mediasession/MediaSession.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::playInternal): If the paused attribute is true and the readyState attribute has the
value HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA, the media element becomes an active participating element of the
media session.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185424
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-06-10 Matt Rajca <mrajca@apple.com>
+
+ Explicitly keep track of active HTMLMediaElements in MediaSessions.
+ https://bugs.webkit.org/show_bug.cgi?id=145829
+
+ Reviewed by Eric Carlson.
+
+ * Modules/mediasession/MediaSession.cpp: Add support for keeping track of active media elements.
+ (WebCore::MediaSession::addActiveMediaElement):
+ * Modules/mediasession/MediaSession.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::playInternal): If the paused attribute is true and the readyState attribute has the
+ value HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA, the media element becomes an active participating element of the
+ media session.
+
2015-06-10 Chris Dumez <cdumez@apple.com>
Drop unused argument for Node::didNotifySubtreeInsertions()
2015-06-10 Chris Dumez <cdumez@apple.com>
Drop unused argument for Node::didNotifySubtreeInsertions()
m_participatingElements.remove(m_participatingElements.find(&element));
}
m_participatingElements.remove(m_participatingElements.find(&element));
}
-Vector<HTMLMediaElement*> MediaSession::activeParticipatingElements() const
+void MediaSession::addActiveMediaElement(HTMLMediaElement& element)
- Vector<HTMLMediaElement*> elements;
-
- for (auto* element : m_participatingElements) {
- if (element->isPlaying())
- elements.append(element);
- }
-
- return elements;
+ m_activeParticipatingElements.add(&element);
}
void MediaSession::releaseSession()
}
void MediaSession::releaseSession()
void MediaSession::togglePlayback()
{
void MediaSession::togglePlayback()
{
- for (auto* element : activeParticipatingElements()) {
+ for (auto* element : m_activeParticipatingElements) {
if (element->paused())
element->play();
else
if (element->paused())
element->play();
else
void addMediaElement(HTMLMediaElement&);
void removeMediaElement(HTMLMediaElement&);
void addMediaElement(HTMLMediaElement&);
void removeMediaElement(HTMLMediaElement&);
- Vector<HTMLMediaElement*> activeParticipatingElements() const;
+ void addActiveMediaElement(HTMLMediaElement&);
State m_currentState { State::Idle };
Vector<HTMLMediaElement*> m_participatingElements;
State m_currentState { State::Idle };
Vector<HTMLMediaElement*> m_participatingElements;
+ HashSet<HTMLMediaElement*> m_activeParticipatingElements;
const String m_kind;
RefPtr<MediaRemoteControls> m_controls;
const String m_kind;
RefPtr<MediaRemoteControls> m_controls;
scheduleEvent(eventNames().waitingEvent);
else if (m_readyState >= HAVE_FUTURE_DATA)
scheduleEvent(eventNames().playingEvent);
scheduleEvent(eventNames().waitingEvent);
else if (m_readyState >= HAVE_FUTURE_DATA)
scheduleEvent(eventNames().playingEvent);
+
+#if ENABLE(MEDIA_SESSION)
+ // 6.3 Activating a media session from a media element
+ // When the play() method is invoked, the paused attribute is true, and the readyState attribute has the value
+ // HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA, then
+ // 1. Let media session be the value of the current media session.
+ // 2. If we are not currently in media session's list of active participating media elements then append
+ // ourselves to this list.
+ if (m_readyState == HAVE_ENOUGH_DATA || m_readyState == HAVE_FUTURE_DATA) {
+ if (m_session)
+ m_session->addActiveMediaElement(*this);
+ }
+#endif
}
m_autoplaying = false;
updatePlayState();
}
m_autoplaying = false;
updatePlayState();