Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index f1a270cdece73a6f1201df876ebba5beab02f0df..05575c3ee96e357f9145d2c49c1ed5efa2b64651 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -3113,12 +3113,23 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
// movie time. |
scheduleTimeupdateEvent(false); |
+ // TODO(amogh.bihani): Remove this once chromium change lands (codereview.chromium.org/533543004/). |
double now = currentTime(); |
double dur = duration(); |
+ if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forward) |
+ mediaPlayerEnded(); |
+ |
+ updatePlayState(); |
+} |
+ |
+void HTMLMediaElement::mediaPlayerEnded() |
+{ |
+ WTF_LOG(Media, "HTMLMediaElement::mediaPlayerEnded"); |
+ |
// When the current playback position reaches the end of the media resource when the direction of |
// playback is forwards, then the user agent must follow these steps: |
- if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forward) { |
+ if (!std::isnan(duration()) && directionOfPlayback() == Forward) { |
// If the media element has a loop attribute specified and does not have a current media controller, |
if (loop() && !m_mediaController) { |
m_sentEndEvent = false; |
@@ -3142,9 +3153,9 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
// for the media element's current media controller. |
updateMediaController(); |
} |
- } |
- else |
+ } else { |
m_sentEndEvent = false; |
+ } |
updatePlayState(); |
} |
@@ -3152,6 +3163,7 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
void HTMLMediaElement::mediaPlayerDurationChanged() |
{ |
WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); |
+ refreshCachedTime(); |
// FIXME: Change MediaPlayerClient & WebMediaPlayer to convey |
// the currentTime when the duration change occured. The current |
// WebMediaPlayer implementations always clamp currentTime() to |