Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index 91ef6708e6f5e78594ef9b36ad751aec9955cc39..3ebb8bb7f870add136de722b57d9db90844f86a0 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -2077,6 +2077,13 @@ double HTMLMediaElement::currentTime() const |
if (m_readyState == HAVE_NOTHING) |
return 0; |
+ // currentTime equals the end of the media resource when 'ended' event is fired. |
+ // NOTE: Sometimes it happens that the current playback position is not exactly equal to the media duration, |
+ // especially in Android, which often stops at a time which is smaller that the actual duration. |
+ if (m_sentEndEvent) { |
+ return duration(); |
+ } |
+ |
if (m_seeking) { |
WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); |
return m_lastSeekTime; |
@@ -2102,6 +2109,7 @@ void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat |
exceptionState.throwDOMException(InvalidStateError, "The element is slaved to a MediaController."); |
return; |
} |
+ |
amogh.bihani
2014/09/03 05:19:09
Sorry, I'll remove this in next PS.
scherkus (not reviewing)
2014/09/03 17:16:45
thanks :)
|
seek(time, exceptionState); |
} |
@@ -3093,12 +3101,24 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
// movie time. |
scheduleTimeupdateEvent(false); |
+ // TODO(amogh.bihani): Remove this once chromium change lands.---------------- |
scherkus (not reviewing)
2014/09/03 17:16:45
can you avoid using the "-----" comments? we don't
|
double now = currentTime(); |
double dur = duration(); |
+ if (!std::isnan(dur) && dur && now >= dur && directionOfPlayback() == Forward) |
+ mediaPlayerEnded(); |
+ // --------------------------------------------------------------------------- |
scherkus (not reviewing)
2014/09/03 17:16:45
remove this whole line
|
+ |
+ 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; |
@@ -3122,9 +3142,9 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
// for the media element's current media controller. |
updateMediaController(); |
} |
- } |
- else |
+ } else { |
m_sentEndEvent = false; |
+ } |
updatePlayState(); |
} |