Changeset 185424 in webkit


Ignore:
Timestamp:
Jun 10, 2015 11:43:52 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Explicitly keep track of active HTMLMediaElements in MediaSessions.
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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185423 r185424  
     12015-06-10  Matt Rajca  <mrajca@apple.com>
     2
     3        Explicitly keep track of active HTMLMediaElements in MediaSessions.
     4        https://bugs.webkit.org/show_bug.cgi?id=145829
     5
     6        Reviewed by Eric Carlson.
     7
     8        * Modules/mediasession/MediaSession.cpp: Add support for keeping track of active media elements.
     9        (WebCore::MediaSession::addActiveMediaElement):
     10        * Modules/mediasession/MediaSession.h:
     11        * html/HTMLMediaElement.cpp:
     12        (WebCore::HTMLMediaElement::playInternal): If the paused attribute is true and the readyState attribute has the
     13          value HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA, the media element becomes an active participating element of the
     14          media session.
     15
    1162015-06-10  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp

    r185394 r185424  
    6767}
    6868
    69 Vector<HTMLMediaElement*> MediaSession::activeParticipatingElements() const
     69void MediaSession::addActiveMediaElement(HTMLMediaElement& element)
    7070{
    71     Vector<HTMLMediaElement*> elements;
    72 
    73     for (auto* element : m_participatingElements) {
    74         if (element->isPlaying())
    75             elements.append(element);
    76     }
    77 
    78     return elements;
     71    m_activeParticipatingElements.add(&element);
    7972}
    8073
     
    8578void MediaSession::togglePlayback()
    8679{
    87     for (auto* element : activeParticipatingElements()) {
     80    for (auto* element : m_activeParticipatingElements) {
    8881        if (element->paused())
    8982            element->play();
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.h

    r185394 r185424  
    6666    void removeMediaElement(HTMLMediaElement&);
    6767
    68     Vector<HTMLMediaElement*> activeParticipatingElements() const;
     68    void addActiveMediaElement(HTMLMediaElement&);
    6969
    7070    State m_currentState { State::Idle };
    7171    Vector<HTMLMediaElement*> m_participatingElements;
     72    HashSet<HTMLMediaElement*> m_activeParticipatingElements;
    7273
    7374    const String m_kind;
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r185270 r185424  
    28302830        else if (m_readyState >= HAVE_FUTURE_DATA)
    28312831            scheduleEvent(eventNames().playingEvent);
     2832
     2833#if ENABLE(MEDIA_SESSION)
     2834        // 6.3 Activating a media session from a media element
     2835        // When the play() method is invoked, the paused attribute is true, and the readyState attribute has the value
     2836        // HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA, then
     2837        // 1. Let media session be the value of the current media session.
     2838        // 2. If we are not currently in media session's list of active participating media elements then append
     2839        //    ourselves to this list.
     2840        if (m_readyState == HAVE_ENOUGH_DATA || m_readyState == HAVE_FUTURE_DATA) {
     2841            if (m_session)
     2842                m_session->addActiveMediaElement(*this);
     2843        }
     2844#endif
    28322845    }
    28332846    m_autoplaying = false;
Note: See TracChangeset for help on using the changeset viewer.