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) { ...@@ -887,6 +887,15 @@ var filterBufferedRanges = function(predicate) {
887 time = tech.currentTime(); 887 time = tech.currentTime();
888 } 888 }
889 889
890 // IE 11 has a bug where it will report a the video as fully buffered
891 // before any data has been loaded. This is a work around where we
892 // report a fully empty buffer until SourceBuffers have been created
893 // which is after a segment has been loaded and transmuxed.
894 if (!this.mediaSource ||
895 !this.mediaSource.mediaSource_.sourceBuffers.length) {
896 return videojs.createTimeRanges([]);
897 }
898
890 if (buffered && buffered.length) { 899 if (buffered && buffered.length) {
891 // Search for a range containing the play-head 900 // Search for a range containing the play-head
892 for (i = 0; i < buffered.length; i++) { 901 for (i = 0; i < buffered.length; i++) {
......
...@@ -164,7 +164,13 @@ var ...@@ -164,7 +164,13 @@ var
164 164
165 // a no-op MediaSource implementation to allow synchronous testing 165 // a no-op MediaSource implementation to allow synchronous testing
166 MockMediaSource = videojs.extend(videojs.EventTarget, { 166 MockMediaSource = videojs.extend(videojs.EventTarget, {
167 constructor: function() {}, 167 constructor: function() {
168 this.mediaSource_ = {
169 // Mock a fake sourceBuffer array because of an IE11 work-around
170 // in `filterBufferedRanges`
171 sourceBuffers: ['fake']
172 };
173 },
168 duration: NaN, 174 duration: NaN,
169 seekable: videojs.createTimeRange(), 175 seekable: videojs.createTimeRange(),
170 addSeekableRange_: function(start, end) { 176 addSeekableRange_: function(start, end) {
...@@ -708,6 +714,33 @@ test('starts downloading a segment on loadedmetadata', function() { ...@@ -708,6 +714,33 @@ test('starts downloading a segment on loadedmetadata', function() {
708 'the first segment is requested'); 714 'the first segment is requested');
709 }); 715 });
710 716
717 test('always returns an empty buffered region when there are no SourceBuffers', function() {
718 player.src({
719 src: 'manifest/media.m3u8',
720 type: 'application/vnd.apple.mpegurl'
721 });
722 player.tech_.buffered = function() {
723 return videojs.createTimeRanges([[0, 10]]);
724 };
725 openMediaSource(player);
726
727 standardXHRResponse(requests[0]);
728 standardXHRResponse(requests[1]);
729 player.currentTime(3);
730 clock.tick(1);
731
732 equal(player.tech_.hls.findBufferedRange_().end(0),
733 10,
734 'inside the first buffered region');
735
736 // Simulate the condition with no source buffers
737 player.hls.mediaSource.mediaSource_.sourceBuffers = [];
738
739 equal(player.tech_.hls.findBufferedRange_().length,
740 0,
741 'empty TimeRanges returned');
742 });
743
711 test('finds the correct buffered region based on currentTime', function() { 744 test('finds the correct buffered region based on currentTime', function() {
712 player.src({ 745 player.src({
713 src: 'manifest/media.m3u8', 746 src: 'manifest/media.m3u8',
......