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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2039793005: Don't resume paused media. Don't resume playing media after timeout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure OnHidden() actually happened. Created 4 years, 6 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 832433691bd68828415cd0e6ee98628d11754c88..5c0ce9192e0e69a4600e0fdd9142d5fa3f6db2a7 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -1112,12 +1112,31 @@ void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) {
void WebMediaPlayerImpl::OnHidden() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
+
+ // Don't allow paused players to resume when shown. It's important to check
+ // this here since |delegate_state_| is generally cleared during suspend.
sandersd (OOO until July 31) 2016/06/07 01:41:16 It's worth noting here that PAUSED_BUT_NOT_IDLE is
+ if (delegate_state_ == DelegateState::PAUSED)
+ is_idle_ = true;
+
+ last_hidden_time_ = base::TimeTicks::Now();
UpdatePlayState();
}
void WebMediaPlayerImpl::OnShown() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
must_suspend_ = false;
+
+ // Don't auto-resume playback on players that have been idle for some time.
+ // We don't do this when seeking since Blink is waiting for the seeked event
+ // and will get into a bad state if we try and suspend.
sandersd (OOO until July 31) 2016/06/07 01:41:16 "try to suspend."
+ if (!paused_ && !seeking_ && !last_hidden_time_.is_null() &&
sandersd (OOO until July 31) 2016/06/07 01:41:16 If this is intended to match DelegateState::PAUSED
+ base::TimeTicks::Now() - last_hidden_time_ >
+ base::TimeDelta::FromSeconds(5)) {
+ OnPause();
sandersd (OOO until July 31) 2016/06/07 01:41:16 Since OnPause() calls UpdatePlayState(), it's prob
+ is_idle_ = true;
+ }
+
+ last_hidden_time_ = base::TimeTicks();
UpdatePlayState();
}
« 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