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

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

Issue 517593003: Allow HTMLMediaElement.currentTime to be set before the transition to HAVE_METADATA (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
« Source/core/html/HTMLMediaElement.h ('K') | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | 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..3ac7fb361e4a8d52d83bcdc7aa87ff4502ab0289 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -324,6 +324,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
, m_duration(std::numeric_limits<double>::quiet_NaN())
, m_lastTimeUpdateEventWallTime(0)
, m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max())
+ , m_defaultPlaybackStartPosition(0)
, m_loadState(WaitingForSource)
, m_deferredLoadState(NotDeferred)
, m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
@@ -1822,6 +1823,12 @@ void HTMLMediaElement::setReadyState(ReadyState state)
if (isHTMLVideoElement())
scheduleEvent(EventTypeNames::resize);
scheduleEvent(EventTypeNames::loadedmetadata);
+
+ if (m_defaultPlaybackStartPosition > 0) {
philipj_slow 2014/09/02 13:03:31 This looks like the correct place for this logic,
amogh.bihani 2014/09/02 13:39:54 Acknowledged.
+ seek(m_defaultPlaybackStartPosition, IGNORE_EXCEPTION);
+ m_defaultPlaybackStartPosition = 0;
+ }
+
if (hasMediaControls())
mediaControls()->reset();
if (renderer())
@@ -1928,9 +1935,10 @@ void HTMLMediaElement::seek(double time, ExceptionState& exceptionState)
// 4.8.10.9 Seeking
- // 1 - If the media element's readyState is HAVE_NOTHING, then raise an InvalidStateError exception.
+ // 1 - If the media element's readyState is HAVE_NOTHING, then set the default playback start
+ // position to that time.
if (m_readyState == HAVE_NOTHING) {
- exceptionState.throwDOMException(InvalidStateError, "The element's readyState is HAVE_NOTHING.");
+ m_defaultPlaybackStartPosition = time;
philipj_slow 2014/09/02 13:03:31 This should be moved to setCurrentTime, per "if th
amogh.bihani 2014/09/02 13:39:54 Acknowledged.
return;
}
@@ -2075,7 +2083,7 @@ double HTMLMediaElement::currentTime() const
#endif
if (m_readyState == HAVE_NOTHING)
- return 0;
+ return m_defaultPlaybackStartPosition;
philipj_slow 2014/09/02 13:03:31 The spec says "return the media element's default
amogh.bihani 2014/09/02 13:39:54 Ok, I'll do that. I thought that its value is set
if (m_seeking) {
WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime);
@@ -2102,6 +2110,12 @@ void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat
exceptionState.throwDOMException(InvalidStateError, "The element is slaved to a MediaController.");
return;
}
+
+ if (m_networkState == NETWORK_EMPTY) {
+ exceptionState.throwDOMException(InvalidStateError, "There is no media attached.");
philipj_slow 2014/09/02 13:03:31 This condition is not in the spec, why is it neede
amogh.bihani 2014/09/02 13:39:54 Oh Sorry! I got confused with this line "Test that
+ return;
+ }
+
seek(time, exceptionState);
}
« Source/core/html/HTMLMediaElement.h ('K') | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698