Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 898883003: Fixes play seek when user sets loop after ended. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Responding to feedback #3 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(LoopCondition::Ignored))
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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 3238
3236 if (m_mediaSource) 3239 if (m_mediaSource)
3237 return m_mediaSource->seekable(); 3240 return m_mediaSource->seekable();
3238 3241
3239 return TimeRanges::create(webMediaPlayer()->seekable()); 3242 return TimeRanges::create(webMediaPlayer()->seekable());
3240 } 3243 }
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 in 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
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(LoopCondition loopCondition) const
3257 { 3260 {
3258 double dur = duration(); 3261 double dur = duration();
3259 if (!m_player || std::isnan(dur)) 3262 if (!m_player || std::isnan(dur))
3260 return false; 3263 return false;
3261 3264
3262 // 4.8.10.8 Playing the media resource 3265 // 4.8.10.8 Playing the media resource
3263 3266
3264 // A media element is said to have ended playback when the element's 3267 // A media element is said to have ended playback when the element's
3265 // readyState attribute is HAVE_METADATA or greater, 3268 // readyState attribute is HAVE_METADATA or greater,
3266 if (m_readyState < HAVE_METADATA) 3269 if (m_readyState < HAVE_METADATA)
3267 return false; 3270 return false;
3268 3271
3269 // and the current playback position is the end of the media resource and th e direction 3272 // 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, 3273 // 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. 3274 // or the media element has a current media controller.
3272 double now = currentTime(); 3275 double now = currentTime();
3273 if (directionOfPlayback() == Forward) 3276 if (directionOfPlayback() == Forward)
3274 return dur > 0 && now >= dur && (!loop() || m_mediaController); 3277 return dur > 0 && now >= dur && (loopCondition == LoopCondition::Ignored || !loop() || m_mediaController);
3275 3278
3276 // or the current playback position is the earliest possible position and th e direction 3279 // or the current playback position is the earliest possible position and th e direction
3277 // of playback is backwards 3280 // of playback is backwards
3278 ASSERT(directionOfPlayback() == Backward); 3281 ASSERT(directionOfPlayback() == Backward);
3279 return now <= 0; 3282 return now <= 0;
3280 } 3283 }
3281 3284
3282 bool HTMLMediaElement::stoppedDueToErrors() const 3285 bool HTMLMediaElement::stoppedDueToErrors() const
3283 { 3286 {
3284 if (m_readyState >= HAVE_METADATA && m_error) { 3287 if (m_readyState >= HAVE_METADATA && m_error) {
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 3973
3971 #if ENABLE(WEB_AUDIO) 3974 #if ENABLE(WEB_AUDIO)
3972 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3975 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3973 { 3976 {
3974 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3977 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3975 audioSourceProvider()->setClient(nullptr); 3978 audioSourceProvider()->setClient(nullptr);
3976 } 3979 }
3977 #endif 3980 #endif
3978 3981
3979 } 3982 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698