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

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

Issue 209223002: Add support for HTMLMediaElement::getStartDate() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Place code behind a runtime flag and add LayoutTest. Created 6 years, 7 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
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index d5095be123ec94c9de987eebce36db2928a6ed73..1b70f84390926b0d47217d88bb4721f7e86b4577 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -251,6 +251,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
, m_lastSeekTime(0)
, m_previousProgressTime(numeric_limits<double>::max())
, m_duration(numeric_limits<double>::quiet_NaN())
+ , m_timelineOffset(numeric_limits<double>::quiet_NaN())
, m_lastTimeUpdateEventWallTime(0)
, m_lastTimeUpdateEventMovieTime(numeric_limits<double>::max())
, m_loadState(WaitingForSource)
@@ -676,6 +677,8 @@ void HTMLMediaElement::prepareForLoad()
invalidateCachedTime();
// 4.9 - Set the timeline offset to Not-a-Number (NaN).
+ m_timelineOffset = numeric_limits<double>::quiet_NaN();
+
// 4.10 - Update the duration attribute to Not-a-Number (NaN).
@@ -1602,11 +1605,32 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state)
}
if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) {
+ // This block corresponds to the "Once enough of the media data has been fetched to determine the duration of the media resource, its dimensions, and other metadata"
+ // section of step 4 of the resource fetch algorithm.
+
+ // FIXME: This appears to correspond to step 10 in the algorithm. Investigate moving this code to a position that matches the spec text.
prepareMediaFragmentURI();
+
+ // 1. Establish the media timeline for the purposes of the current playback position, the earliest possible position, and the initial playback position, based on the media data.
+ // 2. Update the timeline offset to the date and time that corresponds to the zero time in the media timeline established in the previous step, if any. If no explicit time and date is given by the media resource, the timeline offset must be set to Not-a-Number (NaN).
philipj_slow 2014/05/06 11:13:52 Nit: this is a very long line. There isn't a lot o
+ m_timelineOffset = webMediaPlayer()->timelineOffset();
+
+ // 3. Set the current playback position and the official playback position to the earliest possible position.
+
+ // 4. Update the duration attribute with the time of the last frame of the resource, if known, on the media timeline established above. If it is not known (e.g. a stream that is in principle infinite), update the duration attribute to the value positive Infinity.
scheduleEvent(EventTypeNames::durationchange);
+
+ // 5. For video elements, set the videoWidth and videoHeight attributes, and queue a task to fire a simple event named resize at the media element.
if (isHTMLVideoElement(*this))
scheduleEvent(EventTypeNames::resize);
+
+ // 6. Set the readyState attribute to HAVE_METADATA.
+ // Note: A loadedmetadata DOM event will be fired as part of setting the readyState attribute to a new value.
scheduleEvent(EventTypeNames::loadedmetadata);
+
+ // Steps 7-12 appear to be handled elsewhere.
+ // FIXME: Code should be refactored to make it easier to verify that these steps are implemented according to spec.
+
if (hasMediaControls())
mediaControls()->reset();
if (renderer())
@@ -1914,6 +1938,11 @@ double HTMLMediaElement::duration() const
return m_player->duration();
}
+double HTMLMediaElement::getStartDate()
+{
+ return m_timelineOffset;
philipj_slow 2014/05/15 11:38:00 My colleague has noticed that this value will be w
acolwell GONE FROM CHROMIUM 2014/05/15 13:01:22 It is already supposed to be in milliseconds since
philipj_slow 2014/05/15 13:28:29 Thanks!
+}
+
bool HTMLMediaElement::paused() const
{
return m_paused;

Powered by Google App Engine
This is Rietveld 408576698