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

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: 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/core/html/MediaController.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..945b89f944bae98e695a5bd01ae8aaea325efa21 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) {
amogh.bihani 2014/09/03 13:14:32 I tested locally for fragment URI and, as you had
philipj_slow 2014/09/03 14:09:13 Whichever you prefer is OK with me, but I would li
+ seek(m_defaultPlaybackStartPosition);
+ m_defaultPlaybackStartPosition = 0;
+ }
+
if (hasMediaControls())
mediaControls()->reset();
if (renderer())
@@ -1922,18 +1929,12 @@ void HTMLMediaElement::prepareToPlay()
startDeferredLoad();
}
-void HTMLMediaElement::seek(double time, ExceptionState& exceptionState)
+void HTMLMediaElement::seek(double time)
{
WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time);
// 4.8.10.9 Seeking
- // 1 - If the media element's readyState is HAVE_NOTHING, then raise an InvalidStateError exception.
- if (m_readyState == HAVE_NOTHING) {
- exceptionState.throwDOMException(InvalidStateError, "The element's readyState is HAVE_NOTHING.");
- return;
- }
-
// If the media engine has been told to postpone loading data, let it go ahead now.
if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA)
prepareToPlay();
@@ -2074,6 +2075,11 @@ double HTMLMediaElement::currentTime() const
static const double minCachedDeltaForWarning = 0.01;
#endif
+ if (m_defaultPlaybackStartPosition) {
+ ASSERT(m_readyState == HAVE_NOTHING);
+ return m_defaultPlaybackStartPosition;
+ }
+
if (m_readyState == HAVE_NOTHING)
return 0;
@@ -2102,7 +2108,15 @@ void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat
exceptionState.throwDOMException(InvalidStateError, "The element is slaved to a MediaController.");
return;
}
- seek(time, exceptionState);
+
+ // If the media element's readyState is HAVE_NOTHING, then set the default
+ // playback start position to that time.
+ if (m_readyState == HAVE_NOTHING) {
+ m_defaultPlaybackStartPosition = time;
+ return;
+ }
+
+ seek(time);
}
double HTMLMediaElement::duration() const
@@ -2241,7 +2255,7 @@ void HTMLMediaElement::playInternal()
scheduleDelayedAction(LoadMediaResource);
if (endedPlayback())
- seek(0, IGNORE_EXCEPTION);
+ seek(0);
if (m_mediaController)
m_mediaController->bringElementUpToSpeed(this);
@@ -3103,7 +3117,7 @@ void HTMLMediaElement::mediaPlayerTimeChanged()
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);
+ seek(0);
} 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
@@ -3157,7 +3171,7 @@ void HTMLMediaElement::durationChanged(double duration, bool requestSeek)
renderer()->updateFromElement();
if (requestSeek)
- seek(duration, IGNORE_EXCEPTION);
+ seek(duration);
}
void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
@@ -3188,10 +3202,10 @@ void HTMLMediaElement::mediaPlayerRequestSeek(double time)
{
// The player is the source of this seek request.
if (m_mediaController) {
- m_mediaController->setCurrentTime(time, IGNORE_EXCEPTION);
+ m_mediaController->setCurrentTime(time);
return;
}
- setCurrentTime(time, IGNORE_EXCEPTION);
+ setCurrentTime(time, ASSERT_NO_EXCEPTION);
}
// MediaPlayerPresentation methods
@@ -3889,7 +3903,7 @@ void HTMLMediaElement::applyMediaFragmentURI()
if (m_fragmentStartTime != MediaPlayer::invalidTime()) {
m_sentEndEvent = false;
UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragmentStart);
- seek(m_fragmentStartTime, IGNORE_EXCEPTION);
+ seek(m_fragmentStartTime);
}
}
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/MediaController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698