2be08fa4 by jrivera

Work around a bug with the buffered property in IE11 that prevented playback

1 parent 2f10ecfc
......@@ -887,6 +887,15 @@ var filterBufferedRanges = function(predicate) {
time = tech.currentTime();
}
// IE 11 has a bug where it will report a the video as fully buffered
// before any data has been loaded. This is a work around where we
// report a fully empty buffer until SourceBuffers have been created
// which is after a segment has been loaded and transmuxed.
if (!this.mediaSource ||
!this.mediaSource.mediaSource_.sourceBuffers.length) {
return videojs.createTimeRanges([]);
}
if (buffered && buffered.length) {
// Search for a range containing the play-head
for (i = 0; i < buffered.length; i++) {
......
......@@ -164,7 +164,13 @@ var
// a no-op MediaSource implementation to allow synchronous testing
MockMediaSource = videojs.extend(videojs.EventTarget, {
constructor: function() {},
constructor: function() {
this.mediaSource_ = {
// Mock a fake sourceBuffer array because of an IE11 work-around
// in `filterBufferedRanges`
sourceBuffers: ['fake']
};
},
duration: NaN,
seekable: videojs.createTimeRange(),
addSeekableRange_: function(start, end) {
......@@ -708,6 +714,33 @@ test('starts downloading a segment on loadedmetadata', function() {
'the first segment is requested');
});
test('always returns an empty buffered region when there are no SourceBuffers', function() {
player.src({
src: 'manifest/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
player.tech_.buffered = function() {
return videojs.createTimeRanges([[0, 10]]);
};
openMediaSource(player);
standardXHRResponse(requests[0]);
standardXHRResponse(requests[1]);
player.currentTime(3);
clock.tick(1);
equal(player.tech_.hls.findBufferedRange_().end(0),
10,
'inside the first buffered region');
// Simulate the condition with no source buffers
player.hls.mediaSource.mediaSource_.sourceBuffers = [];
equal(player.tech_.hls.findBufferedRange_().length,
0,
'empty TimeRanges returned');
});
test('finds the correct buffered region based on currentTime', function() {
player.src({
src: 'manifest/media.m3u8',
......