Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index 91ef6708e6f5e78594ef9b36ad751aec9955cc39..d69b86aff931e36fced6bf60685f14f42d42caa7 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -3093,6 +3093,7 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
// movie time. |
scheduleTimeupdateEvent(false); |
+ // TODO(amogh.bihani): Remove this once chromium change lands.----------------------------------------- |
double now = currentTime(); |
double dur = duration(); |
@@ -3125,6 +3126,44 @@ void HTMLMediaElement::mediaPlayerTimeChanged() |
} |
else |
m_sentEndEvent = false; |
+ // ---------------------------------------------------------------------------------------------------- |
+ |
+ updatePlayState(); |
+} |
+ |
+void HTMLMediaElement::mediaPlayerEnded() |
scherkus (not reviewing)
2014/09/02 20:23:54
one thing that's tricky is that with this new code
amogh.bihani
2014/09/03 05:17:18
Done.
|
+{ |
+ 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(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; |
+ // then seek to the earliest possible position of the media resource and abort these steps. |
+ seek(0, IGNORE_EXCEPTION); |
+ } else { |
+ // If the media element does not have a current media controller, and the media element |
+ // has still ended playback, and the direction of playback is still forwards, and paused |
+ // is false, |
+ if (!m_mediaController && !m_paused) { |
+ // changes paused to true and fires a simple event named pause at the media element. |
+ m_paused = true; |
+ scheduleEvent(EventTypeNames::pause); |
+ } |
+ // Queue a task to fire a simple event named ended at the media element. |
+ if (!m_sentEndEvent) { |
+ m_sentEndEvent = true; |
+ scheduleEvent(EventTypeNames::ended); |
+ } |
+ // If the media element has a current media controller, then report the controller state |
+ // for the media element's current media controller. |
+ updateMediaController(); |
+ } |
+ } else { |
+ m_sentEndEvent = false; |
+ } |
updatePlayState(); |
} |