b88ac744 by Jon-Carlos Rivera

Merge pull request #573 from videojs/fix-ie11

Work around a bug with the buffered property in IE11 that prevented playback
2 parents dd5d71c9 98b3fc0b
......@@ -305,6 +305,7 @@ const filterBufferedRanges = function(predicate) {
let i;
let ranges = [];
let tech = this.tech_;
// !!The order of the next two assignments is important!!
// `currentTime` must be equal-to or greater-than the start of the
// buffered range. Flash executes out-of-process so, every value can
......@@ -317,6 +318,15 @@ const 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++) {
......
......@@ -172,6 +172,11 @@ class MockMediaSource extends videojs.EventTarget {
super();
this.duration = NaN;
this.seekable = videojs.createTimeRange();
this.mediaSource_ = {
// Mock a fake sourceBuffer array because of an IE11 work-around
// in `filterBufferedRanges`
sourceBuffers: ['fake']
};
}
addSeekableRange_(start, end) {
this.seekable = videojs.createTimeRange(start, end);
......@@ -747,6 +752,33 @@ QUnit.test('starts downloading a segment on loadedmetadata', function() {
'the first segment is requested');
});
QUnit.test('always returns an empty buffered region when there are no SourceBuffers', function() {
this.player.src({
src: 'manifest/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
this.player.tech_.buffered = function() {
return videojs.createTimeRanges([[0, 10]]);
};
openMediaSource(this.player, this.clock);
standardXHRResponse(this.requests[0]);
standardXHRResponse(this.requests[1]);
this.player.currentTime(3);
this.clock.tick(1);
QUnit.equal(this.player.tech_.hls.findBufferedRange_().end(0),
10,
'inside the first buffered region');
// Simulate the condition with no source buffers
this.player.hls.mediaSource.mediaSource_.sourceBuffers = [];
QUnit.equal(this.player.tech_.hls.findBufferedRange_().length,
0,
'empty TimeRanges returned');
});
QUnit.test('finds the correct buffered region based on currentTime', function() {
this.player.src({
src: 'manifest/media.m3u8',
......