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

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

Issue 388803005: Eliminate MediaPlayer abstraction(seek, duration, poster APIs) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: updated as per review Created 6 years, 5 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 | « no previous file | Source/core/html/HTMLVideoElement.cpp » ('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 47ff94fc3839dea3267e41b5cf18f1695e933b32..0f3abbd8167dec80ce4e6a65453b92fe1296623d 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -1903,7 +1903,7 @@ 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.
- if (m_readyState == HAVE_NOTHING || !m_player) {
+ if (m_readyState == HAVE_NOTHING) {
exceptionState.throwDOMException(InvalidStateError, "The element's readyState is HAVE_NOTHING.");
return;
}
@@ -1981,7 +1981,7 @@ void HTMLMediaElement::seek(double time, ExceptionState& exceptionState)
scheduleEvent(EventTypeNames::seeking);
// 9 - Set the current playback position to the given new playback position
- m_player->seek(time);
+ webMediaPlayer()->seek(time);
// 10-14 are handled, if necessary, when the engine signals a readystate change or otherwise
// satisfies seek completion and signals a time change.
@@ -2021,7 +2021,10 @@ bool HTMLMediaElement::seeking() const
void HTMLMediaElement::refreshCachedTime() const
{
- m_cachedTime = m_player->currentTime();
+ if (!webMediaPlayer())
+ return;
+
+ m_cachedTime = webMediaPlayer()->currentTime();
m_cachedTimeWallClockUpdateTime = WTF::currentTime();
}
@@ -2045,7 +2048,7 @@ double HTMLMediaElement::currentTime() const
static const double minCachedDeltaForWarning = 0.01;
#endif
- if (!m_player)
+ if (m_readyState == HAVE_NOTHING)
return 0;
if (m_seeking) {
@@ -2055,7 +2058,7 @@ double HTMLMediaElement::currentTime() const
if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) {
#if LOG_CACHED_TIME_WARNINGS
- double delta = m_cachedTime - m_player->currentTime();
+ double delta = m_cachedTime - webMediaPlayer()->currentTime();
if (delta > minCachedDeltaForWarning)
WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta);
#endif
@@ -2078,7 +2081,7 @@ void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionStat
double HTMLMediaElement::duration() const
{
- if (!m_player || m_readyState < HAVE_METADATA)
+ if (m_readyState < HAVE_METADATA)
return std::numeric_limits<double>::quiet_NaN();
// FIXME: Refactor so m_duration is kept current (in both MSE and
@@ -2094,7 +2097,7 @@ double HTMLMediaElement::duration() const
if (m_mediaSource)
return m_mediaSource->duration();
- return m_player->duration();
+ return webMediaPlayer()->duration();
}
bool HTMLMediaElement::paused() const
@@ -3028,7 +3031,7 @@ void HTMLMediaElement::mediaPlayerTimeChanged()
invalidateCachedTime();
// 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with the seek.
- if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking())
+ if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->seeking())
finishSeek();
// Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
« no previous file with comments | « no previous file | Source/core/html/HTMLVideoElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698