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

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

Issue 370203004: Eliminate MediaPlayer abstraction(play/pause, other APIs) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: updated as per the comment 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 | « Source/core/html/HTMLMediaElement.h ('k') | Source/platform/graphics/media/MediaPlayer.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 5b710d42c174b936b741b68e5aec125c0c761bfc..6d5c10d55dfe3ce3ff77473f5b76730b946d5a8e 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -1878,7 +1878,7 @@ void HTMLMediaElement::addPlayedRange(double start, double end)
bool HTMLMediaElement::supportsSave() const
{
- return m_player ? m_player->supportsSave() : false;
+ return webMediaPlayer() && webMediaPlayer()->supportsSave();
}
void HTMLMediaElement::prepareToPlay()
@@ -1934,12 +1934,13 @@ void HTMLMediaElement::seek(double time, ExceptionState& exceptionState)
// time scale, we will ask the media engine to "seek" to the current movie time, which may be a noop and
// not generate a timechanged callback. This means m_seeking will never be cleared and we will never
// fire a 'seeked' event.
+ double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time);
+ if (time != mediaTime) {
#if !LOG_DISABLED
- double mediaTime = m_player->mediaTimeForTimeValue(time);
- if (time != mediaTime)
WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent is %f", time, mediaTime);
#endif
- time = m_player->mediaTimeForTimeValue(time);
+ time = mediaTime;
+ }
// 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the
// seekable attribute, then let it be the position in one of the ranges given in the seekable attribute
@@ -3107,7 +3108,7 @@ void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
if (!m_player || m_pausedInternal)
return;
- if (m_player->paused())
+ if (webMediaPlayer()->paused())
pause();
else
playInternal();
@@ -3270,9 +3271,10 @@ void HTMLMediaElement::updatePlayState()
if (!m_player)
return;
+ bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
if (m_pausedInternal) {
- if (!m_player->paused())
- m_player->pause();
+ if (isPlaying)
+ webMediaPlayer()->pause();
refreshCachedTime();
m_playbackProgressTimer.stop();
if (hasMediaControls())
@@ -3281,22 +3283,20 @@ void HTMLMediaElement::updatePlayState()
}
bool shouldBePlaying = potentiallyPlaying();
- bool playerPaused = m_player->paused();
- WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, playerPaused = %s",
- boolString(shouldBePlaying), boolString(playerPaused));
+ WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, isPlaying = %s",
+ boolString(shouldBePlaying), boolString(isPlaying));
if (shouldBePlaying) {
setDisplayMode(Video);
invalidateCachedTime();
- if (playerPaused) {
+ if (!isPlaying) {
// Set rate, muted before calling play in case they were set before the media engine was setup.
// The media engine should just stash the rate and muted values since it isn't already playing.
webMediaPlayer()->setRate(effectivePlaybackRate());
updateVolume();
-
- m_player->play();
+ webMediaPlayer()->play();
}
if (hasMediaControls())
@@ -3305,8 +3305,8 @@ void HTMLMediaElement::updatePlayState()
m_playing = true;
} else { // Should not be playing right now
- if (!playerPaused)
- m_player->pause();
+ if (isPlaying)
+ webMediaPlayer()->pause();
refreshCachedTime();
m_playbackProgressTimer.stop();
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/platform/graphics/media/MediaPlayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698