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

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 530993002: WebMediaPlayerImpl should notify ended event Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing comments Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/platform/graphics/media/MediaPlayer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/platform/graphics/media/MediaPlayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698