OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 #endif | 310 #endif |
311 , m_emeMode(EmeModeNotSelected) | 311 , m_emeMode(EmeModeNotSelected) |
312 { | 312 { |
313 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 313 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
314 | 314 |
315 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 315 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
316 ScriptWrappable::init(this); | 316 ScriptWrappable::init(this); |
317 | 317 |
318 if (document.settings()) { | 318 if (document.settings()) { |
319 if (document.settings()->mediaPlaybackRequiresUserGesture()) { | 319 if (document.settings()->mediaPlaybackRequiresUserGesture()) { |
320 addBehaviorRestriction(RequireUserGestureForRateChangeRestriction); | 320 addBehaviorRestriction(RequireUserGestureForPlayRestriction); |
321 addBehaviorRestriction(RequireUserGestureForLoadRestriction); | 321 addBehaviorRestriction(RequireUserGestureForLoadRestriction); |
322 } | 322 } |
323 if (document.settings()->mediaFullscreenRequiresUserGesture()) { | 323 if (document.settings()->mediaFullscreenRequiresUserGesture()) { |
324 addBehaviorRestriction(RequireUserGestureForFullscreenRestriction); | 324 addBehaviorRestriction(RequireUserGestureForFullscreenRestriction); |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 // We must always have a ShadowRoot so children like <source> will not rende r | 328 // We must always have a ShadowRoot so children like <source> will not rende r |
329 // as they never have an insertion point. | 329 // as they never have an insertion point. |
330 ensureUserAgentShadowRoot(); | 330 ensureUserAgentShadowRoot(); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
868 m_muted = true; | 868 m_muted = true; |
869 updateVolume(); | 869 updateVolume(); |
870 | 870 |
871 ASSERT(!m_mediaSource); | 871 ASSERT(!m_mediaSource); |
872 | 872 |
873 bool attemptLoad = true; | 873 bool attemptLoad = true; |
874 | 874 |
875 if (url.protocolIs(mediaSourceBlobProtocol)) { | 875 if (url.protocolIs(mediaSourceBlobProtocol)) { |
876 if (isMediaStreamURL(url.string())) { | 876 if (isMediaStreamURL(url.string())) { |
877 loadType = blink::WebMediaPlayer::LoadTypeMediaStream; | 877 loadType = blink::WebMediaPlayer::LoadTypeMediaStream; |
878 removeBehaviorRestriction(RequireUserGestureForRateChangeRestriction ); | 878 removeBehaviorRestriction(RequireUserGestureForPlayRestriction); |
879 } else { | 879 } else { |
880 m_mediaSource = HTMLMediaSource::lookup(url.string()); | 880 m_mediaSource = HTMLMediaSource::lookup(url.string()); |
881 | 881 |
882 if (m_mediaSource) { | 882 if (m_mediaSource) { |
883 loadType = blink::WebMediaPlayer::LoadTypeMediaSource; | 883 loadType = blink::WebMediaPlayer::LoadTypeMediaSource; |
884 | 884 |
885 if (!m_mediaSource->attachToElement(this)) { | 885 if (!m_mediaSource->attachToElement(this)) { |
886 // Forget our reference to the MediaSource, so we leave it a lone | 886 // Forget our reference to the MediaSource, so we leave it a lone |
887 // while processing remainder of load failure. | 887 // while processing remainder of load failure. |
888 m_mediaSource = 0; | 888 m_mediaSource = 0; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1623 | 1623 |
1624 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { | 1624 if (m_readyState == HAVE_ENOUGH_DATA && oldState < HAVE_ENOUGH_DATA && track sAreReady) { |
1625 if (oldState <= HAVE_CURRENT_DATA) | 1625 if (oldState <= HAVE_CURRENT_DATA) |
1626 scheduleEvent(EventTypeNames::canplay); | 1626 scheduleEvent(EventTypeNames::canplay); |
1627 | 1627 |
1628 scheduleEvent(EventTypeNames::canplaythrough); | 1628 scheduleEvent(EventTypeNames::canplaythrough); |
1629 | 1629 |
1630 if (isPotentiallyPlaying && oldState <= HAVE_CURRENT_DATA) | 1630 if (isPotentiallyPlaying && oldState <= HAVE_CURRENT_DATA) |
1631 scheduleEvent(EventTypeNames::playing); | 1631 scheduleEvent(EventTypeNames::playing); |
1632 | 1632 |
1633 if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(S andboxAutomaticFeatures) && !userGestureRequiredForRateChange()) { | 1633 if (m_autoplaying && m_paused && autoplay() && !document().isSandboxed(S andboxAutomaticFeatures) && !userGestureRequiredForPlay()) { |
1634 m_paused = false; | 1634 m_paused = false; |
1635 invalidateCachedTime(); | 1635 invalidateCachedTime(); |
1636 scheduleEvent(EventTypeNames::play); | 1636 scheduleEvent(EventTypeNames::play); |
1637 scheduleEvent(EventTypeNames::playing); | 1637 scheduleEvent(EventTypeNames::playing); |
1638 } | 1638 } |
1639 | 1639 |
1640 shouldUpdateDisplayState = true; | 1640 shouldUpdateDisplayState = true; |
1641 } | 1641 } |
1642 | 1642 |
1643 if (shouldUpdateDisplayState) { | 1643 if (shouldUpdateDisplayState) { |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2141 void HTMLMediaElement::setPreload(const AtomicString& preload) | 2141 void HTMLMediaElement::setPreload(const AtomicString& preload) |
2142 { | 2142 { |
2143 WTF_LOG(Media, "HTMLMediaElement::setPreload(%s)", preload.utf8().data()); | 2143 WTF_LOG(Media, "HTMLMediaElement::setPreload(%s)", preload.utf8().data()); |
2144 setAttribute(preloadAttr, preload); | 2144 setAttribute(preloadAttr, preload); |
2145 } | 2145 } |
2146 | 2146 |
2147 void HTMLMediaElement::play() | 2147 void HTMLMediaElement::play() |
2148 { | 2148 { |
2149 WTF_LOG(Media, "HTMLMediaElement::play()"); | 2149 WTF_LOG(Media, "HTMLMediaElement::play()"); |
2150 | 2150 |
2151 if (userGestureRequiredForRateChange() && !UserGestureIndicator::processingU serGesture()) | 2151 if (userGestureRequiredForPlay() && !UserGestureIndicator::processingUserGes ture()) |
2152 return; | 2152 return; |
2153 if (UserGestureIndicator::processingUserGesture()) | 2153 if (UserGestureIndicator::processingUserGesture()) |
2154 removeBehaviorsRestrictionsAfterFirstUserGesture(); | 2154 removeBehaviorsRestrictionsAfterFirstUserGesture(); |
2155 | 2155 |
2156 playInternal(); | 2156 playInternal(); |
2157 } | 2157 } |
2158 | 2158 |
2159 void HTMLMediaElement::playInternal() | 2159 void HTMLMediaElement::playInternal() |
2160 { | 2160 { |
2161 WTF_LOG(Media, "HTMLMediaElement::playInternal"); | 2161 WTF_LOG(Media, "HTMLMediaElement::playInternal"); |
(...skipping 21 matching lines...) Expand all Loading... | |
2183 m_autoplaying = false; | 2183 m_autoplaying = false; |
2184 | 2184 |
2185 updatePlayState(); | 2185 updatePlayState(); |
2186 updateMediaController(); | 2186 updateMediaController(); |
2187 } | 2187 } |
2188 | 2188 |
2189 void HTMLMediaElement::pause() | 2189 void HTMLMediaElement::pause() |
2190 { | 2190 { |
2191 WTF_LOG(Media, "HTMLMediaElement::pause()"); | 2191 WTF_LOG(Media, "HTMLMediaElement::pause()"); |
2192 | 2192 |
2193 if (userGestureRequiredForRateChange() && !UserGestureIndicator::processingU serGesture()) | |
2194 return; | |
2195 | |
2196 pauseInternal(); | |
2197 } | |
2198 | |
2199 | |
2200 void HTMLMediaElement::pauseInternal() | |
2201 { | |
2202 WTF_LOG(Media, "HTMLMediaElement::pauseInternal"); | |
2203 | |
2204 // 4.8.10.9. Playing the media resource | |
philipj_slow
2014/02/10 12:57:40
I removed this comment because it's out-of-date an
| |
2205 if (!m_player || m_networkState == NETWORK_EMPTY) | 2193 if (!m_player || m_networkState == NETWORK_EMPTY) |
2206 scheduleDelayedAction(LoadMediaResource); | 2194 scheduleDelayedAction(LoadMediaResource); |
2207 | 2195 |
2208 m_autoplaying = false; | 2196 m_autoplaying = false; |
2209 | 2197 |
2210 if (!m_paused) { | 2198 if (!m_paused) { |
2211 m_paused = true; | 2199 m_paused = true; |
2212 scheduleTimeupdateEvent(false); | 2200 scheduleTimeupdateEvent(false); |
2213 scheduleEvent(EventTypeNames::pause); | 2201 scheduleEvent(EventTypeNames::pause); |
2214 } | 2202 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2436 } | 2424 } |
2437 | 2425 |
2438 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) | 2426 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) |
2439 { | 2427 { |
2440 ASSERT(m_player); | 2428 ASSERT(m_player); |
2441 | 2429 |
2442 if (m_fragmentEndTime != MediaPlayer::invalidTime() && currentTime() >= m_fr agmentEndTime && m_playbackRate > 0) { | 2430 if (m_fragmentEndTime != MediaPlayer::invalidTime() && currentTime() >= m_fr agmentEndTime && m_playbackRate > 0) { |
2443 m_fragmentEndTime = MediaPlayer::invalidTime(); | 2431 m_fragmentEndTime = MediaPlayer::invalidTime(); |
2444 if (!m_mediaController && !m_paused) { | 2432 if (!m_mediaController && !m_paused) { |
2445 // changes paused to true and fires a simple event named pause at th e media element. | 2433 // changes paused to true and fires a simple event named pause at th e media element. |
2446 pauseInternal(); | 2434 pause(); |
2447 } | 2435 } |
2448 } | 2436 } |
2449 | 2437 |
2450 if (!m_seeking) | 2438 if (!m_seeking) |
2451 scheduleTimeupdateEvent(true); | 2439 scheduleTimeupdateEvent(true); |
2452 | 2440 |
2453 if (!m_playbackRate) | 2441 if (!m_playbackRate) |
2454 return; | 2442 return; |
2455 | 2443 |
2456 if (!m_paused && hasMediaControls()) | 2444 if (!m_paused && hasMediaControls()) |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3122 } | 3110 } |
3123 | 3111 |
3124 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() | 3112 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() |
3125 { | 3113 { |
3126 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); | 3114 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); |
3127 | 3115 |
3128 if (!m_player || m_pausedInternal) | 3116 if (!m_player || m_pausedInternal) |
3129 return; | 3117 return; |
3130 | 3118 |
3131 if (m_player->paused()) | 3119 if (m_player->paused()) |
3132 pauseInternal(); | 3120 pause(); |
3133 else | 3121 else |
3134 playInternal(); | 3122 playInternal(); |
3135 } | 3123 } |
3136 | 3124 |
3137 void HTMLMediaElement::mediaPlayerRequestFullscreen() | 3125 void HTMLMediaElement::mediaPlayerRequestFullscreen() |
3138 { | 3126 { |
3139 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); | 3127 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); |
3140 enterFullscreen(); | 3128 enterFullscreen(); |
3141 } | 3129 } |
3142 | 3130 |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3949 { | 3937 { |
3950 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3938 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
3951 } | 3939 } |
3952 | 3940 |
3953 bool HTMLMediaElement::isInteractiveContent() const | 3941 bool HTMLMediaElement::isInteractiveContent() const |
3954 { | 3942 { |
3955 return fastHasAttribute(controlsAttr); | 3943 return fastHasAttribute(controlsAttr); |
3956 } | 3944 } |
3957 | 3945 |
3958 } | 3946 } |
OLD | NEW |