Chromium Code Reviews| 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 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2292 } | 2292 } |
| 2293 | 2293 |
| 2294 void HTMLMediaElement::playInternal() | 2294 void HTMLMediaElement::playInternal() |
| 2295 { | 2295 { |
| 2296 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 2296 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
| 2297 | 2297 |
| 2298 // 4.8.10.9. Playing the media resource | 2298 // 4.8.10.9. Playing the media resource |
| 2299 if (!m_player || m_networkState == NETWORK_EMPTY) | 2299 if (!m_player || m_networkState == NETWORK_EMPTY) |
| 2300 scheduleDelayedAction(LoadMediaResource); | 2300 scheduleDelayedAction(LoadMediaResource); |
| 2301 | 2301 |
| 2302 if (endedPlayback()) | 2302 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
| 2303 // is ignored to seek back to start in case loop was set after playback | |
| 2304 // ended. See http://crbug.com/364442 | |
| 2305 if (endedPlayback(/* ignore_loop_attr */ true)) | |
|
wolenetz
2015/02/12 22:12:27
nit: I don't see this style of commenting params m
chcunningham
2015/02/13 03:37:29
Perhaps this never should have been a bool. I'm no
| |
| 2303 seek(0); | 2306 seek(0); |
| 2304 | 2307 |
| 2305 if (m_mediaController) | 2308 if (m_mediaController) |
| 2306 m_mediaController->bringElementUpToSpeed(this); | 2309 m_mediaController->bringElementUpToSpeed(this); |
| 2307 | 2310 |
| 2308 if (m_paused) { | 2311 if (m_paused) { |
| 2309 m_paused = false; | 2312 m_paused = false; |
| 2310 invalidateCachedTime(); | 2313 invalidateCachedTime(); |
| 2311 scheduleEvent(EventTypeNames::play); | 2314 scheduleEvent(EventTypeNames::play); |
| 2312 | 2315 |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3241 | 3244 |
| 3242 bool HTMLMediaElement::potentiallyPlaying() const | 3245 bool HTMLMediaElement::potentiallyPlaying() const |
| 3243 { | 3246 { |
| 3244 // "pausedToBuffer" means the media engine's rate is 0, but only because it had to stop playing | 3247 // "pausedToBuffer" means the media engine's rate is 0, but only because it had to stop playing |
| 3245 // when it ran out of buffered data. A movie is this state is "potentially p laying", modulo the | 3248 // when it ran out of buffered data. A movie is this state is "potentially p laying", modulo the |
| 3246 // checks in couldPlayIfEnoughData(). | 3249 // checks in couldPlayIfEnoughData(). |
| 3247 bool pausedToBuffer = m_readyStateMaximum >= HAVE_FUTURE_DATA && m_readyStat e < HAVE_FUTURE_DATA; | 3250 bool pausedToBuffer = m_readyStateMaximum >= HAVE_FUTURE_DATA && m_readyStat e < HAVE_FUTURE_DATA; |
| 3248 return (pausedToBuffer || m_readyState >= HAVE_FUTURE_DATA) && couldPlayIfEn oughData() && !isBlockedOnMediaController(); | 3251 return (pausedToBuffer || m_readyState >= HAVE_FUTURE_DATA) && couldPlayIfEn oughData() && !isBlockedOnMediaController(); |
| 3249 } | 3252 } |
| 3250 | 3253 |
| 3251 bool HTMLMediaElement::couldPlayIfEnoughData() const | 3254 bool HTMLMediaElement::couldPlayIfEnoughData() const |
|
wolenetz
2015/02/12 22:12:27
Should this method also ignore loopAttr w.r.t. end
chcunningham
2015/02/13 03:37:29
I don't think so. I've checked usage in 3 differen
wolenetz
2015/02/13 22:24:23
Acknowledged.
| |
| 3252 { | 3255 { |
| 3253 return !paused() && !endedPlayback() && !stoppedDueToErrors(); | 3256 return !paused() && !endedPlayback() && !stoppedDueToErrors(); |
| 3254 } | 3257 } |
| 3255 | 3258 |
| 3256 bool HTMLMediaElement::endedPlayback() const | 3259 bool HTMLMediaElement::endedPlayback() const |
| 3257 { | 3260 { |
| 3261 // For general usage, presence of the loop attribute should be considered to mean playback | |
| 3262 // has not "ended", as "ended" and "looping" are mutually exclusive. See | |
| 3263 // http://dev.w3.org/html5/spec-preview/media-elements.html#ended-playback | |
| 3264 return endedPlayback(/* ignore_loop_attr */ false); | |
|
wolenetz
2015/02/12 22:12:27
nit: ditto: drop the inline comment?
chcunningham
2015/02/13 03:37:29
Now an enum.
| |
| 3265 } | |
| 3266 | |
| 3267 bool HTMLMediaElement::endedPlayback(bool ignoreLoopAttr) const | |
| 3268 { | |
| 3258 double dur = duration(); | 3269 double dur = duration(); |
| 3259 if (!m_player || std::isnan(dur)) | 3270 if (!m_player || std::isnan(dur)) |
| 3260 return false; | 3271 return false; |
| 3261 | 3272 |
| 3262 // 4.8.10.8 Playing the media resource | 3273 // 4.8.10.8 Playing the media resource |
| 3263 | 3274 |
| 3264 // A media element is said to have ended playback when the element's | 3275 // A media element is said to have ended playback when the element's |
| 3265 // readyState attribute is HAVE_METADATA or greater, | 3276 // readyState attribute is HAVE_METADATA or greater, |
| 3266 if (m_readyState < HAVE_METADATA) | 3277 if (m_readyState < HAVE_METADATA) |
| 3267 return false; | 3278 return false; |
| 3268 | 3279 |
| 3269 // and the current playback position is the end of the media resource and th e direction | 3280 // and the current playback position is the end of the media resource and th e direction |
| 3270 // of playback is forwards, Either the media element does not have a loop at tribute specified, | 3281 // of playback is forwards, Either the media element does not have a loop at tribute specified, |
| 3271 // or the media element has a current media controller. | 3282 // or the media element has a current media controller. |
| 3272 double now = currentTime(); | 3283 double now = currentTime(); |
| 3273 if (directionOfPlayback() == Forward) | 3284 if (directionOfPlayback() == Forward) |
| 3274 return dur > 0 && now >= dur && (!loop() || m_mediaController); | 3285 return dur > 0 && now >= dur && (ignoreLoopAttr || !loop() || m_mediaCon troller); |
| 3275 | 3286 |
| 3276 // or the current playback position is the earliest possible position and th e direction | 3287 // or the current playback position is the earliest possible position and th e direction |
| 3277 // of playback is backwards | 3288 // of playback is backwards |
| 3278 ASSERT(directionOfPlayback() == Backward); | 3289 ASSERT(directionOfPlayback() == Backward); |
| 3279 return now <= 0; | 3290 return now <= 0; |
| 3280 } | 3291 } |
| 3281 | 3292 |
| 3282 bool HTMLMediaElement::stoppedDueToErrors() const | 3293 bool HTMLMediaElement::stoppedDueToErrors() const |
| 3283 { | 3294 { |
| 3284 if (m_readyState >= HAVE_METADATA && m_error) { | 3295 if (m_readyState >= HAVE_METADATA && m_error) { |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3970 | 3981 |
| 3971 #if ENABLE(WEB_AUDIO) | 3982 #if ENABLE(WEB_AUDIO) |
| 3972 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3983 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3973 { | 3984 { |
| 3974 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3985 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3975 audioSourceProvider()->setClient(nullptr); | 3986 audioSourceProvider()->setClient(nullptr); |
| 3976 } | 3987 } |
| 3977 #endif | 3988 #endif |
| 3978 | 3989 |
| 3979 } | 3990 } |
| OLD | NEW |