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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2979893002: media: Allow suspend on HTTP 200 videos (Closed)
Patch Set: layout test fix Created 3 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
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index b4ac7396574ddf0f96e24852279038e3dd3f6ede..0c00b97351d446b4f6230a40d44d9ee4841dca24 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -1820,6 +1820,11 @@ void WebMediaPlayerImpl::DataSourceInitialized(bool success) {
return;
}
+ // No point in preloading data as we'll probably just throw it away anyways.
+ if (IsStreaming() && preload_ > MultibufferDataSource::METADATA) {
+ data_source_->SetPreload(MultibufferDataSource::METADATA);
+ }
+
StartPipeline();
}
@@ -2100,7 +2105,18 @@ void WebMediaPlayerImpl::UpdatePlayState() {
bool can_auto_suspend = true;
#else
bool is_remote = false;
- bool can_auto_suspend = !disable_pipeline_auto_suspend_ && !IsStreaming();
+ bool can_auto_suspend = !disable_pipeline_auto_suspend_;
+ // For streaming videos, we only allow suspending at the very beginning of the
+ // video, and only if we know the length of the video. (If we don't know
+ // the length, it might be a dynamically generated video, and suspending
+ // will not work at all.)
+ if (IsStreaming()) {
+ bool at_beginning =
+ ready_state_ == WebMediaPlayer::kReadyStateHaveNothing ||
+ CurrentTime() == 0.0;
+ if (!at_beginning || GetPipelineMediaDuration() == kInfiniteDuration)
+ can_auto_suspend = false;
+ }
#endif
bool is_suspended = pipeline_controller_.IsSuspended();

Powered by Google App Engine
This is Rietveld 408576698