Always preroll unless we've reached kReadyStateHaveFutureData.

Even though we'd like to stop earlier if an element isn't playing, we
can't know if the page is waiting for canplaythrough, so we must buffer
until that point so the event fires.

This is a partial revert of d71061f027f18f15d2d197681a49154f6c14d531's
behavior. We still handle play/pause at kReadyStateHaveMetaData, but
unfortunately the preroll attempt is still needed.

TODO: Instead of prerolling non-playing tags past metadata, we might
instead signal kReadyStateHaveFutureData upon suspend to avoid wasting

TODO: Clearly this behavior is missing a test. :|


Change-Id: I967ab2c4f8297f8f2e7f9ea91dab7e04f9b88880
Reviewed-by: Dale Curtis <>
Commit-Queue: Dale Curtis <>
Cr-Commit-Position: refs/heads/master@{#662084}
diff --git a/media/blink/ b/media/blink/
index 4cc7bd0..4bee34e 100644
--- a/media/blink/
+++ b/media/blink/
@@ -1148,7 +1148,14 @@
   // TODO(sandersd): Replace with |highest_ready_state_since_seek_| if we need
   // to ensure that preroll always gets a chance to complete.
   // See
-  if (highest_ready_state_ >= ReadyState::kReadyStateHaveMetadata)
+  //
+  // Note: Even though we get play/pause signals at kReadyStateHaveMetadata, we
+  // must attempt to preroll until kReadyStateHaveFutureData so that the
+  // canplaythrough event will be fired to the page (which may be waiting).
+  //
+  // TODO(dalecurtis): We should try signaling kReadyStateHaveFutureData upon
+  // automatic-suspend of a non-playing element to avoid wasting resources.
+  if (highest_ready_state_ >= ReadyState::kReadyStateHaveFutureData)
     return false;
   // To suspend before we reach kReadyStateHaveCurrentData is only ok