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 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 if (m_playbackRate != rate) { | 2112 if (m_playbackRate != rate) { |
2113 m_playbackRate = rate; | 2113 m_playbackRate = rate; |
2114 invalidateCachedTime(); | 2114 invalidateCachedTime(); |
2115 scheduleEvent(EventTypeNames::ratechange); | 2115 scheduleEvent(EventTypeNames::ratechange); |
2116 } | 2116 } |
2117 | 2117 |
2118 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) | 2118 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media
Controller) |
2119 m_player->setRate(rate); | 2119 m_player->setRate(rate); |
2120 } | 2120 } |
2121 | 2121 |
| 2122 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co
nst |
| 2123 { |
| 2124 return m_playbackRate >= 0 ? Forward : Backward; |
| 2125 } |
| 2126 |
2122 void HTMLMediaElement::updatePlaybackRate() | 2127 void HTMLMediaElement::updatePlaybackRate() |
2123 { | 2128 { |
2124 double effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; | 2129 double effectiveRate = m_mediaController ? m_mediaController->playbackRate()
: m_playbackRate; |
2125 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) | 2130 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate) |
2126 m_player->setRate(effectiveRate); | 2131 m_player->setRate(effectiveRate); |
2127 } | 2132 } |
2128 | 2133 |
2129 bool HTMLMediaElement::ended() const | 2134 bool HTMLMediaElement::ended() const |
2130 { | 2135 { |
2131 // 4.8.10.8 Playing the media resource | 2136 // 4.8.10.8 Playing the media resource |
2132 // The ended attribute must return true if the media element has ended | 2137 // The ended attribute must return true if the media element has ended |
2133 // playback and the direction of playback is forwards, and false otherwise. | 2138 // playback and the direction of playback is forwards, and false otherwise. |
2134 return endedPlayback() && m_playbackRate > 0; | 2139 return endedPlayback() && directionOfPlayback() == Forward; |
2135 } | 2140 } |
2136 | 2141 |
2137 bool HTMLMediaElement::autoplay() const | 2142 bool HTMLMediaElement::autoplay() const |
2138 { | 2143 { |
2139 return fastHasAttribute(autoplayAttr); | 2144 return fastHasAttribute(autoplayAttr); |
2140 } | 2145 } |
2141 | 2146 |
2142 String HTMLMediaElement::preload() const | 2147 String HTMLMediaElement::preload() const |
2143 { | 2148 { |
2144 switch (m_preload) { | 2149 switch (m_preload) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 return; | 2320 return; |
2316 | 2321 |
2317 m_previousProgressTime = WTF::currentTime(); | 2322 m_previousProgressTime = WTF::currentTime(); |
2318 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER
E); | 2323 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER
E); |
2319 } | 2324 } |
2320 | 2325 |
2321 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) | 2326 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) |
2322 { | 2327 { |
2323 ASSERT(m_player); | 2328 ASSERT(m_player); |
2324 | 2329 |
2325 if (m_fragmentEndTime != MediaPlayer::invalidTime() && currentTime() >= m_fr
agmentEndTime && m_playbackRate > 0) { | 2330 if (m_fragmentEndTime != MediaPlayer::invalidTime() && currentTime() >= m_fr
agmentEndTime && directionOfPlayback() == Forward) { |
2326 m_fragmentEndTime = MediaPlayer::invalidTime(); | 2331 m_fragmentEndTime = MediaPlayer::invalidTime(); |
2327 if (!m_mediaController && !m_paused) { | 2332 if (!m_mediaController && !m_paused) { |
2328 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra
gmentEnd); | 2333 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra
gmentEnd); |
2329 // changes paused to true and fires a simple event named pause at th
e media element. | 2334 // changes paused to true and fires a simple event named pause at th
e media element. |
2330 pause(); | 2335 pause(); |
2331 } | 2336 } |
2332 } | 2337 } |
2333 | 2338 |
2334 if (!m_seeking) | 2339 if (!m_seeking) |
2335 scheduleTimeupdateEvent(true); | 2340 scheduleTimeupdateEvent(true); |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, | 3017 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, |
3013 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current | 3018 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current |
3014 // movie time. | 3019 // movie time. |
3015 scheduleTimeupdateEvent(false); | 3020 scheduleTimeupdateEvent(false); |
3016 | 3021 |
3017 double now = currentTime(); | 3022 double now = currentTime(); |
3018 double dur = duration(); | 3023 double dur = duration(); |
3019 | 3024 |
3020 // When the current playback position reaches the end of the media resource
when the direction of | 3025 // When the current playback position reaches the end of the media resource
when the direction of |
3021 // playback is forwards, then the user agent must follow these steps: | 3026 // playback is forwards, then the user agent must follow these steps: |
3022 if (!std::isnan(dur) && dur && now >= dur && m_playbackRate > 0) { | 3027 if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forwar
d) { |
3023 // If the media element has a loop attribute specified and does not have
a current media controller, | 3028 // If the media element has a loop attribute specified and does not have
a current media controller, |
3024 if (loop() && !m_mediaController) { | 3029 if (loop() && !m_mediaController) { |
3025 m_sentEndEvent = false; | 3030 m_sentEndEvent = false; |
3026 // then seek to the earliest possible position of the media resourc
e and abort these steps. | 3031 // then seek to the earliest possible position of the media resourc
e and abort these steps. |
3027 seek(0, IGNORE_EXCEPTION); | 3032 seek(0, IGNORE_EXCEPTION); |
3028 } else { | 3033 } else { |
3029 // If the media element does not have a current media controller, an
d the media element | 3034 // If the media element does not have a current media controller, an
d the media element |
3030 // has still ended playback, and the direction of playback is still
forwards, and paused | 3035 // has still ended playback, and the direction of playback is still
forwards, and paused |
3031 // is false, | 3036 // is false, |
3032 if (!m_mediaController && !m_paused) { | 3037 if (!m_mediaController && !m_paused) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3192 | 3197 |
3193 // A media element is said to have ended playback when the element's | 3198 // A media element is said to have ended playback when the element's |
3194 // readyState attribute is HAVE_METADATA or greater, | 3199 // readyState attribute is HAVE_METADATA or greater, |
3195 if (m_readyState < HAVE_METADATA) | 3200 if (m_readyState < HAVE_METADATA) |
3196 return false; | 3201 return false; |
3197 | 3202 |
3198 // and the current playback position is the end of the media resource and th
e direction | 3203 // and the current playback position is the end of the media resource and th
e direction |
3199 // of playback is forwards, Either the media element does not have a loop at
tribute specified, | 3204 // of playback is forwards, Either the media element does not have a loop at
tribute specified, |
3200 // or the media element has a current media controller. | 3205 // or the media element has a current media controller. |
3201 double now = currentTime(); | 3206 double now = currentTime(); |
3202 if (m_playbackRate > 0) | 3207 if (directionOfPlayback() == Forward) |
3203 return dur > 0 && now >= dur && (!loop() || m_mediaController); | 3208 return dur > 0 && now >= dur && (!loop() || m_mediaController); |
3204 | 3209 |
3205 // or the current playback position is the earliest possible position and th
e direction | 3210 // or the current playback position is the earliest possible position and th
e direction |
3206 // of playback is backwards | 3211 // of playback is backwards |
3207 if (m_playbackRate < 0) | 3212 ASSERT(directionOfPlayback() == Backward); |
3208 return now <= 0; | 3213 return now <= 0; |
3209 | |
3210 return false; | |
3211 } | 3214 } |
3212 | 3215 |
3213 bool HTMLMediaElement::stoppedDueToErrors() const | 3216 bool HTMLMediaElement::stoppedDueToErrors() const |
3214 { | 3217 { |
3215 if (m_readyState >= HAVE_METADATA && m_error) { | 3218 if (m_readyState >= HAVE_METADATA && m_error) { |
3216 RefPtr<TimeRanges> seekableRanges = seekable(); | 3219 RefPtr<TimeRanges> seekableRanges = seekable(); |
3217 if (!seekableRanges->contain(currentTime())) | 3220 if (!seekableRanges->contain(currentTime())) |
3218 return true; | 3221 return true; |
3219 } | 3222 } |
3220 | 3223 |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3946 | 3949 |
3947 #if ENABLE(WEB_AUDIO) | 3950 #if ENABLE(WEB_AUDIO) |
3948 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3951 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3949 { | 3952 { |
3950 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3953 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
3951 audioSourceProvider()->setClient(0); | 3954 audioSourceProvider()->setClient(0); |
3952 } | 3955 } |
3953 #endif | 3956 #endif |
3954 | 3957 |
3955 } | 3958 } |
OLD | NEW |