Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index d950813509f57be4ced709d0b6c95b819abd7b1e..a244282d0338957f6a9d7357b32324ccd17582ea 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -2299,7 +2299,10 @@ void HTMLMediaElement::playInternal() |
if (!m_player || m_networkState == NETWORK_EMPTY) |
scheduleDelayedAction(LoadMediaResource); |
- if (endedPlayback()) |
+ // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
+ // is ignored to seek back to start in case loop was set after playback |
+ // ended. See http://crbug.com/364442 |
+ if (endedPlayback(LoopFactor::Ignored)) |
seek(0); |
if (m_mediaController) |
@@ -3242,7 +3245,7 @@ PassRefPtrWillBeRawPtr<TimeRanges> HTMLMediaElement::seekable() const |
bool HTMLMediaElement::potentiallyPlaying() const |
{ |
// "pausedToBuffer" means the media engine's rate is 0, but only because it had to stop playing |
- // when it ran out of buffered data. A movie is this state is "potentially playing", modulo the |
+ // when it ran out of buffered data. A movie in this state is "potentially playing", modulo the |
// checks in couldPlayIfEnoughData(). |
bool pausedToBuffer = m_readyStateMaximum >= HAVE_FUTURE_DATA && m_readyState < HAVE_FUTURE_DATA; |
return (pausedToBuffer || m_readyState >= HAVE_FUTURE_DATA) && couldPlayIfEnoughData() && !isBlockedOnMediaController(); |
@@ -3255,6 +3258,14 @@ bool HTMLMediaElement::couldPlayIfEnoughData() const |
bool HTMLMediaElement::endedPlayback() const |
{ |
+ // For general usage, presence of the loop attribute should be considered to mean playback |
+ // has not "ended", as "ended" and "looping" are mutually exclusive. See |
+ // http://dev.w3.org/html5/spec-preview/media-elements.html#ended-playback |
fs
2015/02/13 11:49:22
Make this link
https://html.spec.whatwg.org/multi
chcunningham
2015/02/13 23:01:43
Done. Now in the .h since its an explanation of th
|
+ return endedPlayback(LoopFactor::Included); |
+} |
+ |
+bool HTMLMediaElement::endedPlayback(LoopFactor loopFactor) const |
+{ |
double dur = duration(); |
if (!m_player || std::isnan(dur)) |
return false; |
@@ -3271,7 +3282,7 @@ bool HTMLMediaElement::endedPlayback() const |
// or the media element has a current media controller. |
double now = currentTime(); |
if (directionOfPlayback() == Forward) |
- return dur > 0 && now >= dur && (!loop() || m_mediaController); |
+ return dur > 0 && now >= dur && (loopFactor == LoopFactor::Ignored || !loop() || m_mediaController); |
// or the current playback position is the earliest possible position and the direction |
// of playback is backwards |