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

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

Issue 539103002: Seeking media fragment URI before loadeddata event (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@HAVE_NOTHING
Patch Set: renaming test and 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') | 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 a709141682132ddc3829fd251ecc4500baed28bc..4a6e603d55cc829da858a281a32eed5088f547df 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -332,7 +332,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
, m_preload(MediaPlayer::Auto)
, m_displayMode(Unknown)
, m_cachedTime(MediaPlayer::invalidTime())
- , m_fragmentStartTime(MediaPlayer::invalidTime())
, m_fragmentEndTime(MediaPlayer::invalidTime())
, m_pendingActionFlags(0)
, m_userGestureRequiredForPlay(false)
@@ -1808,10 +1807,11 @@ void HTMLMediaElement::setReadyState(ReadyState state)
if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) {
createPlaceholderTracksIfNecessary();
- prepareMediaFragmentURI();
-
selectInitialTracksIfNecessary();
+ MediaFragmentURIParser fragmentParser(m_currentSrc);
+ m_fragmentEndTime = fragmentParser.endTime();
+
m_duration = duration();
scheduleEvent(EventTypeNames::durationchange);
@@ -1819,10 +1819,31 @@ void HTMLMediaElement::setReadyState(ReadyState state)
scheduleEvent(EventTypeNames::resize);
scheduleEvent(EventTypeNames::loadedmetadata);
- if (m_defaultPlaybackStartPosition > 0)
+ bool jumped = false;
+ if (m_defaultPlaybackStartPosition > 0) {
seek(m_defaultPlaybackStartPosition);
-
+ jumped = true;
+ }
m_defaultPlaybackStartPosition = 0;
+
+ double initialPlaybackPosition = fragmentParser.startTime();
+ if (initialPlaybackPosition == MediaPlayer::invalidTime())
+ initialPlaybackPosition = 0;
+
+ if (!jumped && initialPlaybackPosition > 0) {
+ m_sentEndEvent = false;
+ UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragmentStart);
+ seek(initialPlaybackPosition);
+ jumped = true;
+ }
+
+ if (m_mediaController) {
+ if (jumped && initialPlaybackPosition > m_mediaController->currentTime())
+ m_mediaController->setCurrentTime(initialPlaybackPosition);
+ else
+ seek(m_mediaController->currentTime());
+ }
+
if (hasMediaControls())
mediaControls()->reset();
if (renderer())
@@ -1836,7 +1857,6 @@ void HTMLMediaElement::setReadyState(ReadyState state)
shouldUpdateDisplayState = true;
scheduleEvent(EventTypeNames::loadeddata);
setShouldDelayLoadEvent(false);
- applyMediaFragmentURI();
}
bool isPotentiallyPlaying = potentiallyPlaying();
@@ -3851,42 +3871,6 @@ bool HTMLMediaElement::isBlockedOnMediaController() const
return false;
}
-void HTMLMediaElement::prepareMediaFragmentURI()
-{
- MediaFragmentURIParser fragmentParser(m_currentSrc);
- double dur = duration();
-
- double start = fragmentParser.startTime();
- if (start != MediaFragmentURIParser::invalidTimeValue() && start > 0) {
- m_fragmentStartTime = start;
- if (m_fragmentStartTime > dur)
- m_fragmentStartTime = dur;
- } else
- m_fragmentStartTime = MediaPlayer::invalidTime();
-
- double end = fragmentParser.endTime();
- if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_fragmentStartTime) {
- m_fragmentEndTime = end;
- if (m_fragmentEndTime > dur)
- m_fragmentEndTime = dur;
- } else
- m_fragmentEndTime = MediaPlayer::invalidTime();
-
- // FIXME: Add support for selecting tracks by ID with the Media Fragments track dimension.
-
- if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE_FUTURE_DATA)
- prepareToPlay();
-}
-
-void HTMLMediaElement::applyMediaFragmentURI()
-{
- if (m_fragmentStartTime != MediaPlayer::invalidTime()) {
- m_sentEndEvent = false;
- UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragmentStart);
- seek(m_fragmentStartTime);
- }
-}
-
WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
{
const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698