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. :|
Reviewed-by: Dale Curtis <email@example.com>
Commit-Queue: Dale Curtis <firstname.lastname@example.org>
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 4cc7bd0..4bee34e 100644
@@ -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 http://crbug.com/671525.
- 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)
// To suspend before we reach kReadyStateHaveCurrentData is only ok