Changeset 202100 in webkit


Ignore:
Timestamp:
Jun 15, 2016, 12:32:50 PM (9 years ago)
Author:
eric.carlson@apple.com
Message:

[iOS] Make HTMLMediaElement.muted mutable
https://bugs.webkit.org/show_bug.cgi?id=158787
<rdar://problem/24452567>

Reviewed by Dean Jackson.

Source/WebCore:

Tests: media/audio-playback-restriction-removed-muted.html

media/audio-playback-restriction-removed-track-enabled.html

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::audioTrackEnabledChanged): Remove most behavior restrictions if

the track state was changed as a result of a user gesture.

(WebCore::HTMLMediaElement::setMuted): Ditto.
(WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Add mask

parameter so caller can choose which restrictions are removed.

  • html/HTMLMediaElement.h:
  • html/MediaElementSession.cpp:

(WebCore::restrictionName): Drive-by fix: remove duplicate label.

  • html/MediaElementSession.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Set muted on AVPlayer if setMuted

was called before the player was created.

(WebCore::MediaPlayerPrivateAVFoundationObjC::setVolume): Drive-by fix: return early if there

is no AVPlayer, not if we won't have metadata yet.

(WebCore::MediaPlayerPrivateAVFoundationObjC::setMuted): New.

LayoutTests:

  • media/audio-playback-restriction-removed-muted-expected.txt: Added.
  • media/audio-playback-restriction-removed-muted.html: Added.
  • media/audio-playback-restriction-removed-track-enabled-expected.txt: Added.
  • media/audio-playback-restriction-removed-track-enabled.html: Added.
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202097 r202100  
     12016-06-15  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [iOS] Make HTMLMediaElement.muted mutable
     4        https://bugs.webkit.org/show_bug.cgi?id=158787
     5        <rdar://problem/24452567>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * media/audio-playback-restriction-removed-muted-expected.txt: Added.
     10        * media/audio-playback-restriction-removed-muted.html: Added.
     11        * media/audio-playback-restriction-removed-track-enabled-expected.txt: Added.
     12        * media/audio-playback-restriction-removed-track-enabled.html: Added.
     13
    1142016-06-15  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r202091 r202100  
     12016-06-15  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [iOS] Make HTMLMediaElement.muted mutable
     4        https://bugs.webkit.org/show_bug.cgi?id=158787
     5        <rdar://problem/24452567>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Tests: media/audio-playback-restriction-removed-muted.html
     10               media/audio-playback-restriction-removed-track-enabled.html
     11
     12        * html/HTMLMediaElement.cpp:
     13        (WebCore::HTMLMediaElement::audioTrackEnabledChanged): Remove most behavior restrictions if
     14          the track state was changed as a result of a user gesture.
     15        (WebCore::HTMLMediaElement::setMuted): Ditto.
     16        (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Add mask
     17          parameter so caller can choose which restrictions are removed.
     18        * html/HTMLMediaElement.h:
     19
     20        * html/MediaElementSession.cpp:
     21        (WebCore::restrictionName): Drive-by fix: remove duplicate label.
     22        * html/MediaElementSession.h:
     23
     24        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     25        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     26        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Set muted on AVPlayer if setMuted
     27          was called before the player was created.
     28        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVolume): Drive-by fix: return early if there
     29          is no AVPlayer, not if we won't have metadata yet.
     30        (WebCore::MediaPlayerPrivateAVFoundationObjC::setMuted): New.
     31
    1322016-06-15  Romain Bellessort  <romain.bellessort@crf.canon.fr>
    233
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r202005 r202100  
    17581758    if (m_audioTracks && m_audioTracks->contains(*track))
    17591759        m_audioTracks->scheduleChangeEvent();
     1760    if (ScriptController::processingUserGestureForMedia())
     1761        removeBehaviorsRestrictionsAfterFirstUserGesture(MediaElementSession::AllRestrictions & ~MediaElementSession::RequireUserGestureToControlControlsManager);
    17601762}
    17611763
     
    33333335    LOG(Media, "HTMLMediaElement::setMuted(%p) - %s", this, boolString(muted));
    33343336
    3335 #if PLATFORM(IOS)
    3336     UNUSED_PARAM(muted);
    3337 #else
    33383337    if (m_muted != muted || !m_explicitlyMuted) {
    33393338        m_muted = muted;
    33403339        m_explicitlyMuted = true;
     3340
     3341        if (ScriptController::processingUserGestureForMedia())
     3342            removeBehaviorsRestrictionsAfterFirstUserGesture(MediaElementSession::AllRestrictions & ~MediaElementSession::RequireUserGestureToControlControlsManager);
     3343
    33413344        // Avoid recursion when the player reports volume changes.
    33423345        if (!processingMediaPlayerCallback()) {
     
    33613364#endif
    33623365    }
    3363 #endif
    33643366
    33653367    updatePlaybackControlsManager();
     
    64026404#endif
    64036405
    6404 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
    6405 {
    6406     MediaElementSession::BehaviorRestrictions restrictionsToRemove = MediaElementSession::RequireUserGestureForLoad
     6406void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture(MediaElementSession::BehaviorRestrictions mask)
     6407{
     6408    MediaElementSession::BehaviorRestrictions restrictionsToRemove = mask &
     6409        (MediaElementSession::RequireUserGestureForLoad
    64076410#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    64086411        | MediaElementSession::RequireUserGestureToShowPlaybackTargetPicker
     
    64146417        | MediaElementSession::RequireUserGestureForFullscreen
    64156418        | MediaElementSession::InvisibleAutoplayNotPermitted
    6416         | MediaElementSession::RequireUserGestureToControlControlsManager;
     6419        | MediaElementSession::RequireUserGestureToControlControlsManager);
     6420
    64176421    m_mediaSession->removeBehaviorRestriction(restrictionsToRemove);
    64186422}
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r201757 r202100  
    722722    void changeNetworkStateFromLoadingToIdle();
    723723
    724     void removeBehaviorsRestrictionsAfterFirstUserGesture();
     724    void removeBehaviorsRestrictionsAfterFirstUserGesture(MediaElementSession::BehaviorRestrictions mask = MediaElementSession::AllRestrictions);
    725725
    726726    void updateMediaController();
  • trunk/Source/WebCore/html/MediaElementSession.cpp

    r201729 r202100  
    8383    CASE(WirelessVideoPlaybackDisabled);
    8484#endif
    85     CASE(RequireUserGestureForAudioRateChange);
    8685    CASE(InvisibleAutoplayNotPermitted);
    8786    CASE(OverrideUserGestureRequirementForMainContent);
  • trunk/Source/WebCore/html/MediaElementSession.h

    r201729 r202100  
    8787        RequirePageConsentToResumeMedia = 1 << 4,
    8888        RequireUserGestureForAudioRateChange = 1 << 5,
    89 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
    9089        RequireUserGestureToShowPlaybackTargetPicker = 1 << 6,
    9190        WirelessVideoPlaybackDisabled =  1 << 7,
    9291        RequireUserGestureToAutoplayToExternalDevice = 1 << 8,
    93 #endif
    9492        MetadataPreloadingNotPermitted = 1 << 9,
    9593        AutoPreloadingNotPermitted = 1 << 10,
     
    9795        OverrideUserGestureRequirementForMainContent = 1 << 12,
    9896        RequireUserGestureToControlControlsManager = 1 << 13,
     97        AllRestrictions = ~NoRestrictions,
    9998    };
    10099    typedef unsigned BehaviorRestrictions;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r201524 r202100  
    177177    MediaTime currentMediaTime() const override;
    178178    void setVolume(float) override;
     179    bool supportsMuting() const override { return true; }
     180    void setMuted(bool) override;
    179181    void setClosedCaptionsVisible(bool) override;
    180182    void paint(GraphicsContext&, const FloatRect&) override;
     
    425427    bool m_cachedCanPlayFastForward;
    426428    bool m_cachedCanPlayFastReverse;
     429    bool m_muted { false };
    427430#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    428431    mutable bool m_allowsWirelessVideoPlayback;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r202013 r202100  
    10591059#endif
    10601060
     1061    if (m_muted) {
     1062        // Clear m_muted so setMuted doesn't return without doing anything.
     1063        m_muted = false;
     1064        [m_avPlayer.get() setMuted:m_muted];
     1065    }
     1066
    10611067    if (player()->client().mediaPlayerIsVideo())
    10621068        createAVPlayerLayer();
     
    13961402    return;
    13971403#else
    1398     if (!metaDataAvailable())
     1404    if (!m_avPlayer)
    13991405        return;
    14001406
    14011407    [m_avPlayer.get() setVolume:volume];
    14021408#endif
     1409}
     1410
     1411void MediaPlayerPrivateAVFoundationObjC::setMuted(bool muted)
     1412{
     1413    if (m_muted == muted)
     1414        return;
     1415
     1416    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setMuted(%p) - set to %s", this, boolString(muted));
     1417
     1418    m_muted = muted;
     1419
     1420    if (!m_avPlayer)
     1421        return;
     1422
     1423    [m_avPlayer.get() setMuted:m_muted];
    14031424}
    14041425
Note: See TracChangeset for help on using the changeset viewer.