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 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 selectInitialTracksIfNecessary(); | 1818 selectInitialTracksIfNecessary(); |
1819 | 1819 |
1820 m_duration = duration(); | 1820 m_duration = duration(); |
1821 scheduleEvent(EventTypeNames::durationchange); | 1821 scheduleEvent(EventTypeNames::durationchange); |
1822 | 1822 |
1823 if (isHTMLVideoElement()) | 1823 if (isHTMLVideoElement()) |
1824 scheduleEvent(EventTypeNames::resize); | 1824 scheduleEvent(EventTypeNames::resize); |
1825 scheduleEvent(EventTypeNames::loadedmetadata); | 1825 scheduleEvent(EventTypeNames::loadedmetadata); |
1826 | 1826 |
1827 if (m_defaultPlaybackStartPosition > 0) { | 1827 if (m_defaultPlaybackStartPosition > 0) { |
1828 seek(m_defaultPlaybackStartPosition, IGNORE_EXCEPTION); | 1828 seek(m_defaultPlaybackStartPosition); |
1829 m_defaultPlaybackStartPosition = 0; | 1829 m_defaultPlaybackStartPosition = 0; |
1830 } | 1830 } |
1831 | 1831 |
1832 if (hasMediaControls()) | 1832 if (hasMediaControls()) |
1833 mediaControls()->reset(); | 1833 mediaControls()->reset(); |
1834 if (renderer()) | 1834 if (renderer()) |
1835 renderer()->updateFromElement(); | 1835 renderer()->updateFromElement(); |
1836 } | 1836 } |
1837 | 1837 |
1838 bool shouldUpdateDisplayState = false; | 1838 bool shouldUpdateDisplayState = false; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 { | 1922 { |
1923 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); | 1923 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); |
1924 if (m_havePreparedToPlay) | 1924 if (m_havePreparedToPlay) |
1925 return; | 1925 return; |
1926 m_havePreparedToPlay = true; | 1926 m_havePreparedToPlay = true; |
1927 | 1927 |
1928 if (loadIsDeferred()) | 1928 if (loadIsDeferred()) |
1929 startDeferredLoad(); | 1929 startDeferredLoad(); |
1930 } | 1930 } |
1931 | 1931 |
1932 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState) | 1932 void HTMLMediaElement::seek(double time) |
1933 { | 1933 { |
1934 WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time); | 1934 WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time); |
1935 | 1935 |
1936 // 4.8.10.9 Seeking | 1936 // 4.8.10.9 Seeking |
1937 | 1937 |
1938 // 1 - If the media element's readyState is HAVE_NOTHING, then set the defau
lt playback start | 1938 // 1 - If the media element's readyState is HAVE_NOTHING, then set the defau
lt playback start |
1939 // position to that time. | 1939 // position to that time. |
1940 if (m_readyState == HAVE_NOTHING) { | 1940 if (m_readyState == HAVE_NOTHING) { |
1941 m_defaultPlaybackStartPosition = time; | 1941 m_defaultPlaybackStartPosition = time; |
1942 return; | 1942 return; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 if (m_mediaController) { | 2109 if (m_mediaController) { |
2110 exceptionState.throwDOMException(InvalidStateError, "The element is slav
ed to a MediaController."); | 2110 exceptionState.throwDOMException(InvalidStateError, "The element is slav
ed to a MediaController."); |
2111 return; | 2111 return; |
2112 } | 2112 } |
2113 | 2113 |
2114 if (m_networkState == NETWORK_EMPTY) { | 2114 if (m_networkState == NETWORK_EMPTY) { |
2115 exceptionState.throwDOMException(InvalidStateError, "There is no media a
ttached."); | 2115 exceptionState.throwDOMException(InvalidStateError, "There is no media a
ttached."); |
2116 return; | 2116 return; |
2117 } | 2117 } |
2118 | 2118 |
2119 seek(time, exceptionState); | 2119 seek(time); |
2120 } | 2120 } |
2121 | 2121 |
2122 double HTMLMediaElement::duration() const | 2122 double HTMLMediaElement::duration() const |
2123 { | 2123 { |
2124 // FIXME: remove m_player check once we figure out how m_player is going | 2124 // FIXME: remove m_player check once we figure out how m_player is going |
2125 // out of sync with readystate. m_player is cleared but readystate is not se
t | 2125 // out of sync with readystate. m_player is cleared but readystate is not se
t |
2126 // to HAVE_NOTHING | 2126 // to HAVE_NOTHING |
2127 if (!m_player || m_readyState < HAVE_METADATA) | 2127 if (!m_player || m_readyState < HAVE_METADATA) |
2128 return std::numeric_limits<double>::quiet_NaN(); | 2128 return std::numeric_limits<double>::quiet_NaN(); |
2129 | 2129 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 | 2248 |
2249 void HTMLMediaElement::playInternal() | 2249 void HTMLMediaElement::playInternal() |
2250 { | 2250 { |
2251 WTF_LOG(Media, "HTMLMediaElement::playInternal"); | 2251 WTF_LOG(Media, "HTMLMediaElement::playInternal"); |
2252 | 2252 |
2253 // 4.8.10.9. Playing the media resource | 2253 // 4.8.10.9. Playing the media resource |
2254 if (!m_player || m_networkState == NETWORK_EMPTY) | 2254 if (!m_player || m_networkState == NETWORK_EMPTY) |
2255 scheduleDelayedAction(LoadMediaResource); | 2255 scheduleDelayedAction(LoadMediaResource); |
2256 | 2256 |
2257 if (endedPlayback()) | 2257 if (endedPlayback()) |
2258 seek(0, IGNORE_EXCEPTION); | 2258 seek(0); |
2259 | 2259 |
2260 if (m_mediaController) | 2260 if (m_mediaController) |
2261 m_mediaController->bringElementUpToSpeed(this); | 2261 m_mediaController->bringElementUpToSpeed(this); |
2262 | 2262 |
2263 if (m_paused) { | 2263 if (m_paused) { |
2264 m_paused = false; | 2264 m_paused = false; |
2265 invalidateCachedTime(); | 2265 invalidateCachedTime(); |
2266 scheduleEvent(EventTypeNames::play); | 2266 scheduleEvent(EventTypeNames::play); |
2267 | 2267 |
2268 if (m_readyState <= HAVE_CURRENT_DATA) | 2268 if (m_readyState <= HAVE_CURRENT_DATA) |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3110 double now = currentTime(); | 3110 double now = currentTime(); |
3111 double dur = duration(); | 3111 double dur = duration(); |
3112 | 3112 |
3113 // When the current playback position reaches the end of the media resource
when the direction of | 3113 // When the current playback position reaches the end of the media resource
when the direction of |
3114 // playback is forwards, then the user agent must follow these steps: | 3114 // playback is forwards, then the user agent must follow these steps: |
3115 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar
d) { | 3115 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar
d) { |
3116 // If the media element has a loop attribute specified and does not have
a current media controller, | 3116 // If the media element has a loop attribute specified and does not have
a current media controller, |
3117 if (loop() && !m_mediaController) { | 3117 if (loop() && !m_mediaController) { |
3118 m_sentEndEvent = false; | 3118 m_sentEndEvent = false; |
3119 // then seek to the earliest possible position of the media resourc
e and abort these steps. | 3119 // then seek to the earliest possible position of the media resourc
e and abort these steps. |
3120 seek(0, IGNORE_EXCEPTION); | 3120 seek(0); |
3121 } else { | 3121 } else { |
3122 // If the media element does not have a current media controller, an
d the media element | 3122 // If the media element does not have a current media controller, an
d the media element |
3123 // has still ended playback, and the direction of playback is still
forwards, and paused | 3123 // has still ended playback, and the direction of playback is still
forwards, and paused |
3124 // is false, | 3124 // is false, |
3125 if (!m_mediaController && !m_paused) { | 3125 if (!m_mediaController && !m_paused) { |
3126 // changes paused to true and fires a simple event named pause a
t the media element. | 3126 // changes paused to true and fires a simple event named pause a
t the media element. |
3127 m_paused = true; | 3127 m_paused = true; |
3128 scheduleEvent(EventTypeNames::pause); | 3128 scheduleEvent(EventTypeNames::pause); |
3129 } | 3129 } |
3130 // Queue a task to fire a simple event named ended at the media elem
ent. | 3130 // Queue a task to fire a simple event named ended at the media elem
ent. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3164 WTF_LOG(Media, "HTMLMediaElement::durationChanged : %f -> %f", m_duration, d
uration); | 3164 WTF_LOG(Media, "HTMLMediaElement::durationChanged : %f -> %f", m_duration, d
uration); |
3165 m_duration = duration; | 3165 m_duration = duration; |
3166 scheduleEvent(EventTypeNames::durationchange); | 3166 scheduleEvent(EventTypeNames::durationchange); |
3167 | 3167 |
3168 if (hasMediaControls()) | 3168 if (hasMediaControls()) |
3169 mediaControls()->reset(); | 3169 mediaControls()->reset(); |
3170 if (renderer()) | 3170 if (renderer()) |
3171 renderer()->updateFromElement(); | 3171 renderer()->updateFromElement(); |
3172 | 3172 |
3173 if (requestSeek) | 3173 if (requestSeek) |
3174 seek(duration, IGNORE_EXCEPTION); | 3174 seek(duration); |
3175 } | 3175 } |
3176 | 3176 |
3177 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() | 3177 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() |
3178 { | 3178 { |
3179 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); | 3179 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); |
3180 | 3180 |
3181 if (!m_player || m_pausedInternal) | 3181 if (!m_player || m_pausedInternal) |
3182 return; | 3182 return; |
3183 | 3183 |
3184 if (webMediaPlayer()->paused()) | 3184 if (webMediaPlayer()->paused()) |
(...skipping 10 matching lines...) Expand all Loading... |
3195 // user interaction or when it is technically required to play the video. | 3195 // user interaction or when it is technically required to play the video. |
3196 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 3196 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
3197 | 3197 |
3198 enterFullscreen(); | 3198 enterFullscreen(); |
3199 } | 3199 } |
3200 | 3200 |
3201 void HTMLMediaElement::mediaPlayerRequestSeek(double time) | 3201 void HTMLMediaElement::mediaPlayerRequestSeek(double time) |
3202 { | 3202 { |
3203 // The player is the source of this seek request. | 3203 // The player is the source of this seek request. |
3204 if (m_mediaController) { | 3204 if (m_mediaController) { |
3205 m_mediaController->setCurrentTime(time, IGNORE_EXCEPTION); | 3205 m_mediaController->setCurrentTime(time); |
3206 return; | 3206 return; |
3207 } | 3207 } |
3208 setCurrentTime(time, IGNORE_EXCEPTION); | 3208 setCurrentTime(time, ASSERT_NO_EXCEPTION); |
3209 } | 3209 } |
3210 | 3210 |
3211 // MediaPlayerPresentation methods | 3211 // MediaPlayerPresentation methods |
3212 void HTMLMediaElement::mediaPlayerRepaint() | 3212 void HTMLMediaElement::mediaPlayerRepaint() |
3213 { | 3213 { |
3214 if (m_webLayer) | 3214 if (m_webLayer) |
3215 m_webLayer->invalidate(); | 3215 m_webLayer->invalidate(); |
3216 | 3216 |
3217 updateDisplayState(); | 3217 updateDisplayState(); |
3218 if (renderer()) | 3218 if (renderer()) |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3896 | 3896 |
3897 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE
_FUTURE_DATA) | 3897 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE
_FUTURE_DATA) |
3898 prepareToPlay(); | 3898 prepareToPlay(); |
3899 } | 3899 } |
3900 | 3900 |
3901 void HTMLMediaElement::applyMediaFragmentURI() | 3901 void HTMLMediaElement::applyMediaFragmentURI() |
3902 { | 3902 { |
3903 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { | 3903 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { |
3904 m_sentEndEvent = false; | 3904 m_sentEndEvent = false; |
3905 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment
Start); | 3905 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment
Start); |
3906 seek(m_fragmentStartTime, IGNORE_EXCEPTION); | 3906 seek(m_fragmentStartTime); |
3907 } | 3907 } |
3908 } | 3908 } |
3909 | 3909 |
3910 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const | 3910 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const |
3911 { | 3911 { |
3912 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); | 3912 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); |
3913 if (crossOriginMode.isNull()) | 3913 if (crossOriginMode.isNull()) |
3914 return WebMediaPlayer::CORSModeUnspecified; | 3914 return WebMediaPlayer::CORSModeUnspecified; |
3915 if (equalIgnoringCase(crossOriginMode, "use-credentials")) | 3915 if (equalIgnoringCase(crossOriginMode, "use-credentials")) |
3916 return WebMediaPlayer::CORSModeUseCredentials; | 3916 return WebMediaPlayer::CORSModeUseCredentials; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4003 | 4003 |
4004 #if ENABLE(WEB_AUDIO) | 4004 #if ENABLE(WEB_AUDIO) |
4005 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 4005 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
4006 { | 4006 { |
4007 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 4007 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
4008 audioSourceProvider()->setClient(0); | 4008 audioSourceProvider()->setClient(0); |
4009 } | 4009 } |
4010 #endif | 4010 #endif |
4011 | 4011 |
4012 } | 4012 } |
OLD | NEW |