fe517c0e by jforbes

Added an extra null check for mediaSource

1 parent 6a9433a9
...@@ -892,6 +892,7 @@ var filterBufferedRanges = function(predicate) { ...@@ -892,6 +892,7 @@ var filterBufferedRanges = function(predicate) {
892 // report a fully empty buffer until SourceBuffers have been created 892 // report a fully empty buffer until SourceBuffers have been created
893 // which is after a segment has been loaded and transmuxed. 893 // which is after a segment has been loaded and transmuxed.
894 if (!this.mediaSource || 894 if (!this.mediaSource ||
895 !this.mediaSource.mediaSource_ ||
895 !this.mediaSource.mediaSource_.sourceBuffers.length) { 896 !this.mediaSource.mediaSource_.sourceBuffers.length) {
896 return videojs.createTimeRanges([]); 897 return videojs.createTimeRanges([]);
897 } 898 }
......
...@@ -739,6 +739,13 @@ test('always returns an empty buffered region when there are no SourceBuffers', ...@@ -739,6 +739,13 @@ test('always returns an empty buffered region when there are no SourceBuffers',
739 equal(player.tech_.hls.findBufferedRange_().length, 739 equal(player.tech_.hls.findBufferedRange_().length,
740 0, 740 0,
741 'empty TimeRanges returned'); 741 'empty TimeRanges returned');
742
743 // Simulate the condition with no media source
744 player.hls.mediaSource.mediaSource_ = undefined;
745
746 equal(player.tech_.hls.findBufferedRange_().length,
747 0,
748 'empty TimeRanges returned');
742 }); 749 });
743 750
744 test('finds the correct buffered region based on currentTime', function() { 751 test('finds the correct buffered region based on currentTime', function() {
......