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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2644723004: [Video] Don't pause video-only elements if they're already paused... (Closed)
Patch Set: Added PauseVideoIfNeeded Created 3 years, 11 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 | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index d908e699612de5a34dddc5fa6138d31b45e683d3..3194070ab8ba022c3bb0e77a29c646b02fd87f63 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -1161,7 +1161,10 @@ void WebMediaPlayerImpl::OnPipelineResumed() {
is_pipeline_resuming_ = false;
if (IsHidden()) {
- DisableVideoTrackIfNeeded();
+ if (ShouldPauseVideoWhenHidden())
+ PauseVideoIfNeeded();
+ else
+ DisableVideoTrackIfNeeded();
} else {
EnableVideoTrackIfNeeded();
}
@@ -1411,13 +1414,8 @@ void WebMediaPlayerImpl::OnFrameHidden() {
watch_time_reporter_->OnHidden();
if (ShouldPauseVideoWhenHidden()) {
- if (!paused_when_hidden_) {
- // OnPause() will set |paused_when_hidden_| to false and call
- // UpdatePlayState(), so set the flag to true after and then return.
- OnPause();
- paused_when_hidden_ = true;
- return;
- }
+ PauseVideoIfNeeded();
+ return;
} else {
DisableVideoTrackIfNeeded();
}
@@ -2182,6 +2180,16 @@ bool WebMediaPlayerImpl::IsBackgroundOptimizationCandidate() const {
max_keyframe_distance_to_disable_background_video_;
}
+void WebMediaPlayerImpl::PauseVideoIfNeeded() {
+ if (is_pipeline_resuming_ || seeking_ || paused_ || paused_when_hidden_)
sandersd (OOO until July 31) 2017/01/20 21:24:19 Require or DCHECK IsHidden? Do we need to also ch
+ return;
+
+ // OnPause() will set |paused_when_hidden_| to false and call
+ // UpdatePlayState(), so set the flag to true after and then return.
+ OnPause();
+ paused_when_hidden_ = true;
+}
+
void WebMediaPlayerImpl::EnableVideoTrackIfNeeded() {
DCHECK(!IsHidden());
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698