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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 1823643003: Don't suspend before there is metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo Created 4 years, 9 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 | 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 64a44f770d4990fecbb35f8ce4b99328774cdd9f..f49b583b945612668bc6aa5f3da3b076872394c0 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -985,17 +985,16 @@ void WebMediaPlayerImpl::OnPipelineMetadata(
video_weblayer_->layer()->SetContentsOpaque(opaque_);
video_weblayer_->SetContentsOpaqueIsFixed(true);
client_->setWebLayer(video_weblayer_.get());
-
- // If there is video and the frame is hidden, then it may be time to suspend
- // playback.
- if (delegate_ && delegate_->IsHidden())
- OnHidden();
}
// Tell the delegate we can now be safely suspended due to inactivity if a
// subsequent play event does not occur.
if (paused_)
NotifyPlaybackPaused();
+
+ // If the frame is hidden, it may be time to suspend playback.
+ if (delegate_ && delegate_->IsHidden())
+ OnHidden();
}
void WebMediaPlayerImpl::OnPipelineBufferingStateChanged(
@@ -1066,6 +1065,11 @@ void WebMediaPlayerImpl::OnHidden() {
return;
#endif
+ // Don't suspend before metadata is available, as we don't know if there is a
+ // video track yet.
+ if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata)
+ return;
+
// Don't suspend players which only have audio and have not completed
// playback. The user can still control these players via the MediaSession UI.
// If the player has never started playback, OnSuspendRequested() will handle
@@ -1092,8 +1096,15 @@ void WebMediaPlayerImpl::OnShown() {
return;
#endif
- if (!ended_ && !paused_)
+ // If we do not yet have metadata, the only way we could have been suspended
+ // is by a OnSuspendRequested() with |must_suspend| set. In that case we need
+ // to resume, otherwise playback will be broken.
+ //
+ // Otherwise, resume if we should be playing.
+ if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata ||
+ (!ended_ && !paused_)) {
pipeline_controller_.Resume();
+ }
}
void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698