Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index d950813509f57be4ced709d0b6c95b819abd7b1e..e3691d611b95a870d525051a37f85c9eba7f8be2 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(/* 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
|
seek(0); |
if (m_mediaController) |
@@ -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 |
+ 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.
|
+} |
+ |
+bool HTMLMediaElement::endedPlayback(bool ignoreLoopAttr) 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 && (ignoreLoopAttr || !loop() || m_mediaController); |
// or the current playback position is the earliest possible position and the direction |
// of playback is backwards |