Index: media/blink/webmediaplayer_impl.cc |
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc |
index 0fd74e8390402a15d3cc42dd6a12370e7555c171..091df700029f2c24c55aa01af6ba64572a25e780 100644 |
--- a/media/blink/webmediaplayer_impl.cc |
+++ b/media/blink/webmediaplayer_impl.cc |
@@ -478,9 +478,25 @@ blink::WebTimeRanges WebMediaPlayerImpl::buffered() const { |
const base::TimeDelta duration = pipeline_.GetMediaDuration(); |
if (duration != kInfiniteDuration()) { |
- buffered_data_source_host_.AddBufferedTimeRanges( |
- &buffered_time_ranges, duration); |
+ // Demuxed ranges are not useful for a streaming resource, since we can't |
+ // actually seek to those points unless they're cached. Instead report |
+ // buffered() based on the lowest cached byte range. |
+ // |
+ // Technically we could do this for non-streaming resources too since we're |
+ // caching the same amount for them, but the returned range will be shown on |
+ // the controls and historically there's been outcry when gaps are shown. |
+ if (data_source_ && data_source_->IsStreaming()) { |
+ Ranges<base::TimeDelta> cached_ranges; |
+ buffered_data_source_host_.AddBufferedTimeRanges(&cached_ranges, |
+ duration); |
+ buffered_time_ranges = |
+ buffered_time_ranges.IntersectionWith(cached_ranges); |
+ } else { |
+ buffered_data_source_host_.AddBufferedTimeRanges(&buffered_time_ranges, |
+ duration); |
+ } |
} |
+ |
return ConvertToWebTimeRanges(buffered_time_ranges); |
} |